fix: 已有数据库再次安装时接上原库而不是报错
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { NAlert, NButton, NInput } from "naive-ui";
|
||||
import { api, saveSession } from "../../shared/http";
|
||||
import ThemeButton from "../../shell/ThemeButton.vue";
|
||||
|
||||
const props = defineProps<{ purpose?: "login" | "pool" }>();
|
||||
const emit = defineEmits<{ done: [] }>();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const mode = ref("local");
|
||||
const username = ref("");
|
||||
@@ -137,6 +138,7 @@ async function finishNqi() {
|
||||
<div class="brand-mark" aria-hidden="true">D</div>
|
||||
<h1>{{ purpose === "pool" ? "添加账号" : "DecomEval" }}</h1>
|
||||
</div>
|
||||
<n-alert v-if="route.query.notice === 'already'" type="info" style="margin-bottom: 12px">这个数据库已经安装过,请使用原来的管理员账号登录。</n-alert>
|
||||
<n-alert v-if="errorText" type="error" style="margin-bottom: 12px">{{ errorText }}</n-alert>
|
||||
<div class="form-grid">
|
||||
<label>账号</label>
|
||||
|
||||
@@ -40,7 +40,7 @@ async function submit() {
|
||||
busy.value = true;
|
||||
errorText.value = "";
|
||||
try {
|
||||
await api("/api/install", {
|
||||
const result = await api<{ already?: boolean }>("/api/install", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
host: host.value,
|
||||
@@ -53,7 +53,7 @@ async function submit() {
|
||||
}),
|
||||
});
|
||||
markInstalled();
|
||||
router.push("/login");
|
||||
router.push(result.already ? { path: "/login", query: { notice: "already" } } : "/login");
|
||||
} catch (error) {
|
||||
errorText.value = error instanceof Error ? error.message : "安装失败";
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user