refactor: 改用router.push并清除路由守卫缓存替代window.location.href

- 添加resetInstallCheck()清除安装状态缓存
- 安装完成后调用resetInstallCheck再router.push跳转
- 保持SPA无刷新体验
This commit is contained in:
2026-05-03 19:51:31 +08:00
parent fbc2e5ac91
commit a93bc7dfb7
2 changed files with 11 additions and 2 deletions
+6 -2
View File
@@ -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(() => {
+5
View File
@@ -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<boolean> {
if (installChecked) return isInstalled
try {