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

44 lines
1.2 KiB
TypeScript
Raw Normal View History

2026-01-26 13:47:53 +08:00
import { createApp } from 'vue'
2026-02-04 13:30:07 +08:00
import { createPinia } from 'pinia' // [新增] 引入 Pinia
2026-01-26 13:47:53 +08:00
import App from './App.vue'
2026-02-04 13:30:07 +08:00
// 1. 引入路由配置
import router from './router'
2026-02-04 13:30:07 +08:00
// 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'
2026-02-04 13:30:07 +08:00
// 4. 引入全局样式 (通常建议加上,如果没有可忽略)
import './style.css'
const app = createApp(App)
2026-02-04 13:30:07 +08:00
// =========================================================
// [关键修复] 注册顺序非常重要!
// 1. 必须先注册 Pinia,因为 Router 的守卫中会用到 Store
// =========================================================
const pinia = createPinia()
app.use(pinia)
2026-02-04 13:30:07 +08:00
// =========================================================
// 2. 然后注册 Router
// =========================================================
app.use(router)
2026-02-04 13:30:07 +08:00
// 3. 注册 Element Plus
app.use(ElementPlus, {
locale: zhCn, // 设置为中文
})
2026-02-04 13:30:07 +08:00
// 4. 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.component(key, component)
}
app.mount('#app')