feat: complete admin API integration
This commit is contained in:
+25
-1
@@ -1,11 +1,35 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import 'element-plus/es/components/message/style/css'
|
||||
import 'element-plus/es/components/message-box/style/css'
|
||||
import App from './App.vue'
|
||||
import { registerAuthSessionExpiredHandler } from '@/api/http'
|
||||
import router from './router'
|
||||
import { sanitizeInternalPath } from '@/router/accessDecision'
|
||||
import { useAccessPreviewStore } from '@/stores/accessPreview'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useUnsavedWorkStore } from '@/stores/unsavedWork'
|
||||
import './styles/index.css'
|
||||
|
||||
createApp(App).use(createPinia()).use(router).mount('#app')
|
||||
const pinia = createPinia()
|
||||
const auth = useAuthStore(pinia)
|
||||
|
||||
await auth.restoreSession()
|
||||
|
||||
registerAuthSessionExpiredHandler(async () => {
|
||||
const currentRoute = router.currentRoute.value
|
||||
if (currentRoute.name === 'login') return
|
||||
|
||||
useAccessPreviewStore(pinia).reset()
|
||||
useUnsavedWorkStore(pinia).clear()
|
||||
const redirect = sanitizeInternalPath(currentRoute.fullPath)
|
||||
ElMessage.warning('登录状态已过期,请重新登录')
|
||||
await router.replace({
|
||||
name: 'login',
|
||||
query: redirect === '/' ? undefined : { redirect },
|
||||
})
|
||||
})
|
||||
|
||||
createApp(App).use(pinia).use(router).mount('#app')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user