From a93bc7dfb7592f47c75afa5c88fc76d8df283d64 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 3 May 2026 19:51:31 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=94=B9=E7=94=A8router.push?= =?UTF-8?q?=E5=B9=B6=E6=B8=85=E9=99=A4=E8=B7=AF=E7=94=B1=E5=AE=88=E5=8D=AB?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=9B=BF=E4=BB=A3window.location.href?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加resetInstallCheck()清除安装状态缓存 - 安装完成后调用resetInstallCheck再router.push跳转 - 保持SPA无刷新体验 --- frontend/src/pages/install/index.vue | 8 ++++++-- frontend/src/router/guard/index.ts | 5 +++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/install/index.vue b/frontend/src/pages/install/index.vue index 530a1bb..80873f0 100644 --- a/frontend/src/pages/install/index.vue +++ b/frontend/src/pages/install/index.vue @@ -4,6 +4,8 @@ import { computed, onMounted, ref } from 'vue' import { useRouter } from 'vue-router' import { toast } from 'vue-sonner' +import { resetInstallCheck } from '@/router/guard/index' + const router = useRouter() const loading = ref(false) @@ -42,7 +44,8 @@ async function checkInstallStatus() { const data = await res.json() installStatus.value = data?.data if (data?.data?.installed) { - window.location.href = '/login' + resetInstallCheck() + router.push('/login') } } catch (error) { @@ -162,7 +165,8 @@ function goNext() { } function goLogin() { - window.location.href = '/login' + resetInstallCheck() + router.push('/login') } onMounted(() => { diff --git a/frontend/src/router/guard/index.ts b/frontend/src/router/guard/index.ts index d53eb65..a4123e6 100644 --- a/frontend/src/router/guard/index.ts +++ b/frontend/src/router/guard/index.ts @@ -3,6 +3,11 @@ import type { Router } from 'vue-router' let installChecked = false let isInstalled = false +export function resetInstallCheck() { + installChecked = false + isInstalled = false +} + async function checkInstallStatus(): Promise { if (installChecked) return isInstalled try {