Files
KCGL/inventory-web/src/main.ts

50 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { createApp } from 'vue'
import { createPinia } from 'pinia' // [新增] 引入 Pinia
import App from './App.vue'
// 1. 引入路由配置
import router from './router'
// 2. 引入 Element Plus
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
// 引入中文包
import zhCn from 'element-plus/es/locale/lang/zh-cn'
// 3. 引入图标
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// 4. 引入全局样式 (通常建议加上,如果没有可忽略)
import './style.css'
// 5. 引入全局自定义指令
import permissionDirective from './directives/permission'
const app = createApp(App)
// =========================================================
// [关键修复] 注册顺序非常重要!
// 1. 必须先注册 Pinia因为 Router 的守卫中会用到 Store
// =========================================================
const pinia = createPinia()
app.use(pinia)
// =========================================================
// 2. 然后注册 Router
// =========================================================
app.use(router)
// 3. 注册 Element Plus
app.use(ElementPlus, {
locale: zhCn, // 设置为中文
})
// 4. 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}
// 5. 注册全局自定义指令
app.directive('permission', permissionDirective)
app.mount('#app')