131 lines
2.5 KiB
TypeScript
131 lines
2.5 KiB
TypeScript
import { createApp } from 'vue'
|
||
import { createPinia } from 'pinia'
|
||
import ElementPlus from 'element-plus'
|
||
import 'element-plus/dist/index.css'
|
||
|
||
import './assets/css/common.scss'
|
||
|
||
// 注意:shared 的样式现在通过 index.html 中的 <link> 标签加载
|
||
// 不再需要在这里导入:import 'shared/styles'
|
||
|
||
import App from './App.vue'
|
||
import router from './router/'
|
||
import { AES_SECRET_KEY } from './config/index'
|
||
|
||
// 导入需要的 Lucide 图标(用于动态组件)
|
||
import {
|
||
MessageCircle,
|
||
LayoutGrid,
|
||
Workflow,
|
||
FileText,
|
||
Headphones,
|
||
BarChart3,
|
||
Users,
|
||
User,
|
||
Settings,
|
||
Home,
|
||
Ticket,
|
||
Bot,
|
||
ScrollText,
|
||
Monitor,
|
||
Server,
|
||
ChevronDown,
|
||
ChevronRight,
|
||
ChevronLeft,
|
||
PanelLeftClose,
|
||
PanelLeftOpen,
|
||
RefreshCw,
|
||
Loader,
|
||
LogOut,
|
||
Plus,
|
||
Trash2,
|
||
Clock,
|
||
Search,
|
||
AlertTriangle,
|
||
Wrench,
|
||
Paperclip,
|
||
Send,
|
||
History,
|
||
X,
|
||
Menu
|
||
} from 'lucide-vue-next'
|
||
|
||
// Lucide 图标映射(用于全局注册)
|
||
const lucideIcons = {
|
||
MessageCircle,
|
||
LayoutGrid,
|
||
Workflow,
|
||
FileText,
|
||
Headphones,
|
||
BarChart3,
|
||
Users,
|
||
User,
|
||
Settings,
|
||
Home,
|
||
Ticket,
|
||
Bot,
|
||
ScrollText,
|
||
Monitor,
|
||
Server,
|
||
ChevronDown,
|
||
ChevronRight,
|
||
ChevronLeft,
|
||
PanelLeftClose,
|
||
PanelLeftOpen,
|
||
RefreshCw,
|
||
Loader,
|
||
LogOut,
|
||
Plus,
|
||
Trash2,
|
||
Clock,
|
||
Search,
|
||
AlertTriangle,
|
||
Wrench,
|
||
Paperclip,
|
||
Send,
|
||
History,
|
||
X,
|
||
Menu
|
||
}
|
||
|
||
// 异步初始化应用
|
||
async function initApp() {
|
||
// 1. 创建 Vue 应用
|
||
const app = createApp(App)
|
||
|
||
// 2. 注册 Pinia
|
||
const pinia = createPinia()
|
||
app.use(pinia)
|
||
|
||
// 3. 注册 Element Plus
|
||
app.use(ElementPlus)
|
||
|
||
// 4. 注册 Lucide 图标(用于动态组件)
|
||
for (const [name, component] of Object.entries(lucideIcons)) {
|
||
app.component(name, component)
|
||
}
|
||
|
||
// 5. 注册路由
|
||
app.use(router)
|
||
|
||
// 6. 立即挂载应用(不等待 AES 初始化)
|
||
app.mount('#app')
|
||
|
||
console.log('✅ Workcase 应用启动成功')
|
||
|
||
// 7. 后台初始化 AES 加密工具(不阻塞渲染)
|
||
try {
|
||
const { initAesEncrypt } = await import('shared/utils')
|
||
await initAesEncrypt(AES_SECRET_KEY)
|
||
console.log('✅ AES 加密工具初始化成功')
|
||
} catch (error) {
|
||
console.error('❌ AES 加密工具初始化失败:', error)
|
||
}
|
||
}
|
||
|
||
// 启动应用
|
||
console.log('🚀 开始初始化 Workcase 应用...')
|
||
initApp().catch(error => {
|
||
console.error('❌ 应用初始化失败:', error)
|
||
})
|