55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
|
import { createApp } from 'vue'
|
|||
|
import { createPinia } from 'pinia'
|
|||
|
import ElementPlus from 'element-plus'
|
|||
|
import 'element-plus/dist/index.css'
|
|||
|
import 'element-plus/theme-chalk/dark/css-vars.css'
|
|||
|
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
|
|||
|
|
|||
|
import App from './App.vue'
|
|||
|
import router from './router'
|
|||
|
|
|||
|
// 导入全局样式
|
|||
|
import '@/styles/main.scss'
|
|||
|
|
|||
|
// 创建Vue应用实例
|
|||
|
const app = createApp(App)
|
|||
|
|
|||
|
// 创建Pinia实例
|
|||
|
const pinia = createPinia()
|
|||
|
|
|||
|
// 注册Element Plus图标
|
|||
|
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
|||
|
app.component(key, component)
|
|||
|
}
|
|||
|
|
|||
|
// 配置Element Plus
|
|||
|
app.use(ElementPlus, {
|
|||
|
size: 'default',
|
|||
|
zIndex: 3000,
|
|||
|
})
|
|||
|
|
|||
|
// 注册插件
|
|||
|
app.use(pinia)
|
|||
|
app.use(router)
|
|||
|
|
|||
|
// 全局错误处理
|
|||
|
app.config.errorHandler = (err, vm, info) => {
|
|||
|
console.error('Vue应用错误:', err)
|
|||
|
console.error('错误信息:', info)
|
|||
|
console.error('组件实例:', vm)
|
|||
|
}
|
|||
|
|
|||
|
// 全局属性
|
|||
|
app.config.globalProperties.$ELEMENT = { size: 'default', zIndex: 3000 }
|
|||
|
|
|||
|
// 挂载应用
|
|||
|
app.mount('#app')
|
|||
|
|
|||
|
// 开发环境配置
|
|||
|
if (import.meta.env.DEV) {
|
|||
|
console.log('🚀 聊天应用已启动 (开发模式)')
|
|||
|
console.log('📡 API地址:', import.meta.env.VITE_API_BASE_URL || 'http://localhost:3000')
|
|||
|
|
|||
|
// 全局Vue实例(用于调试)
|
|||
|
window.__VUE_APP__ = app
|
|||
|
}
|