feat: 提示统一为可关闭的 toast
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { NAlert, NButton, NInput } from "naive-ui";
|
||||
import { NButton, NInput } from "naive-ui";
|
||||
import { api } from "../../shared/http";
|
||||
import { markInstalled } from "../../shared/installState";
|
||||
import { useToast } from "../../shared/toast";
|
||||
import ThemeButton from "../../shell/ThemeButton.vue";
|
||||
|
||||
const router = useRouter();
|
||||
const toast = useToast();
|
||||
const host = ref("127.0.0.1");
|
||||
const port = ref("5432");
|
||||
const database = ref("decom");
|
||||
@@ -14,7 +16,6 @@ const username = ref("postgres");
|
||||
const password = ref("nixevol@242520");
|
||||
const adminUsername = ref("admin");
|
||||
const adminPassword = ref("nixevol@242520");
|
||||
const errorText = ref("");
|
||||
const busy = ref(false);
|
||||
|
||||
onMounted(async () => {
|
||||
@@ -34,11 +35,10 @@ function allowPort(value: string) {
|
||||
async function submit() {
|
||||
const portNumber = Number(port.value);
|
||||
if (!port.value || portNumber < 1 || portNumber > 65535) {
|
||||
errorText.value = "端口需要在 1 到 65535 之间";
|
||||
toast.error("端口需要在 1 到 65535 之间");
|
||||
return;
|
||||
}
|
||||
busy.value = true;
|
||||
errorText.value = "";
|
||||
try {
|
||||
const result = await api<{ already?: boolean }>("/api/install", {
|
||||
method: "POST",
|
||||
@@ -55,7 +55,7 @@ async function submit() {
|
||||
markInstalled();
|
||||
router.push(result.already ? { path: "/login", query: { notice: "already" } } : "/login");
|
||||
} catch (error) {
|
||||
errorText.value = error instanceof Error ? error.message : "安装失败";
|
||||
toast.error(error instanceof Error ? error.message : "安装失败");
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
@@ -70,7 +70,6 @@ async function submit() {
|
||||
<div class="brand-mark" aria-hidden="true">D</div>
|
||||
<h1>安装 DecomEval</h1>
|
||||
</div>
|
||||
<n-alert v-if="errorText" type="error" style="margin-bottom: 12px">{{ errorText }}</n-alert>
|
||||
<div class="form-grid">
|
||||
<label>数据库主机</label>
|
||||
<n-input v-model:value="host" />
|
||||
|
||||
Reference in New Issue
Block a user