修改加载策略
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
@@ -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')
|
||||||
|
|||||||
Reference in New Issue
Block a user