This commit is contained in:
2026-08-05 15:54:59 +08:00
parent eede351038
commit 4b31eb7786
43 changed files with 2117 additions and 851 deletions
+11 -1
View File
@@ -8,12 +8,15 @@ import router from '@/app/router'
import { sanitizeInternalPath } from '@/core/routing/accessDecision'
import { useAccessPreviewStore } from '@/core/access/accessPreview'
import { useUnsavedWorkStore } from '@/core/unsaved-work/unsavedWork'
import { useWorkspaceTabsStore } from '@/core/workspace-tabs/workspaceTabs'
import { useAuthStore } from '@/core/auth/auth'
import { registerAuthSessionExpiredHandler } from '@/shared/api/http'
import './styles/index.css'
const pinia = createPinia()
const auth = useAuthStore(pinia)
const unsaved = useUnsavedWorkStore(pinia)
const workspace = useWorkspaceTabsStore(pinia)
await auth.restoreSession()
@@ -22,7 +25,8 @@ registerAuthSessionExpiredHandler(async () => {
if (currentRoute.name === 'login') return
useAccessPreviewStore(pinia).reset()
useUnsavedWorkStore(pinia).clear()
unsaved.clear()
workspace.reset(true)
const redirect = sanitizeInternalPath(currentRoute.fullPath)
ElMessage.warning('登录状态已过期,请重新登录')
await router.replace({
@@ -31,4 +35,10 @@ registerAuthSessionExpiredHandler(async () => {
})
})
window.addEventListener('beforeunload', (event) => {
if (!unsaved.entries.some((entry) => entry.dirty)) return
event.preventDefault()
event.returnValue = ''
})
createApp(App).use(pinia).use(router).mount('#app')