修改加载策略

This commit is contained in:
2026-06-11 13:32:21 +08:00
parent 459d919192
commit c1675f9ce5
2 changed files with 6 additions and 8 deletions
-8
View File
@@ -1,13 +1,5 @@
<script setup> <script setup>
import { onMounted } from 'vue'
import { RouterView } from 'vue-router' import { RouterView } from 'vue-router'
import { useUserStore } from '@/stores/user'
// Restore login state from localStorage/sessionStorage
onMounted(() => {
const userStore = useUserStore()
userStore.restoreSession()
})
</script> </script>
<template> <template>
+6
View File
@@ -37,4 +37,10 @@ app.use(pinia)
app.use(router) app.use(router)
app.use(i18n) app.use(i18n)
// 在 mount 前恢复登录状态,确保所有子组件 onMounted 时 isLoggedIn 已正确初始化
// 避免 AiChatView 等组件因时序问题先以"未登录"状态渲染再跃迁
import { useUserStore } from '@/stores/user'
const userStore = useUserStore()
userStore.restoreSession()
app.mount('#app') app.mount('#app')