初次提交
This commit is contained in:
44
src/main.js
Normal file
44
src/main.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import ElementPlus from 'element-plus'
|
||||
import 'element-plus/dist/index.css'
|
||||
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
||||
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
|
||||
import NProgress from 'nprogress'
|
||||
import 'nprogress/nprogress.css'
|
||||
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import { useUserStore } from './stores/user'
|
||||
import './style.css'
|
||||
|
||||
// 配置NProgress
|
||||
NProgress.configure({ showSpinner: false })
|
||||
|
||||
const app = createApp(App)
|
||||
const pinia = createPinia()
|
||||
|
||||
// 注册Element Plus图标
|
||||
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||
app.component(key, component)
|
||||
}
|
||||
|
||||
app.use(pinia)
|
||||
app.use(router)
|
||||
app.use(ElementPlus, {
|
||||
locale: zhCn,
|
||||
})
|
||||
|
||||
// 应用初始化后检查用户状态
|
||||
app.mount('#app')
|
||||
|
||||
// 初始化用户状态检查
|
||||
const userStore = useUserStore()
|
||||
if (userStore.isAuthenticated) {
|
||||
// 如果用户已登录,启动状态检查
|
||||
userStore.checkAuth().then((isValid) => {
|
||||
if (isValid) {
|
||||
userStore.startStatusCheck()
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user