| import { createApp } from 'vue' | |
| import App from './App.vue' | |
| import router from './router' | |
| import store from './store' | |
| // 引入Element Plus | |
| import ElementPlus from 'element-plus' | |
| import 'element-plus/dist/index.css' | |
| import * as ElementPlusIconsVue from '@element-plus/icons-vue' | |
| const app = createApp(App) | |
| // 注册所有Element Plus图标 | |
| for (const [key, component] of Object.entries(ElementPlusIconsVue)) { | |
| app.component(key, component) | |
| } | |
| app.use(ElementPlus) | |
| app.use(store) // 确保这行存在且在 router 之前 | |
| app.use(router) | |
| // 应用启动时恢复登录状态 | |
| if (store && store.dispatch) { | |
| store.dispatch('auth/restoreLoginState') | |
| } | |
| app.mount('#app') |