You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
3.1 KiB
TypeScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* @Author: donghao donghao@supervision.ltd
* @Date: 2025-03-06 11:27:03
* @LastEditors: donghao donghao@supervision.ltd
* @LastEditTime: 2025-03-11 11:11:49
* @FilePath: \vite-ai\data-dashboard\src\main.ts
* @Description: 入口文件
*/
// src/main.ts
import { createApp } from "vue";
import { createPinia } from "pinia";
import App from "./App.vue";
import router from "./router";
// import { mockServer } from './mock' // Mock服务初始化
// import { registerGlobalDirectives } from '@/directives' // 全局指令注册
import { registerErrorHandler } from "@/utils/error"; // 全局错误处理
// ================== 初始化核心配置 ==================
const app = createApp(App);
const pinia = createPinia();
// ================== DataV ==================
// // 引入 DataV
// import DataV from '@jiaminghi/data-view';
// // 引入 DataV 的 CSS 样式
// import '@jiaminghi/data-view/lib/data-view.min.css';
// ================== Element Plus 完整引入方案 ==================
import ElementPlus from "element-plus";
import "@/styles/tailwind.scss";
import "element-plus/dist/index.css";
import "element-plus/theme-chalk/dark/css-vars.css"; // 暗黑主题
import zhCn from "@/plugins/zhCnElement"; // 引入中文语言包
// ================== 自动导入配置检查 ==================
// 确保vite.config.ts中已配置以下内容
// AutoImport({ resolvers: [ElementPlusResolver()] })
// Components({ resolvers: [ElementPlusResolver()] })
// ================== 全局样式导入 ==================
import "@/styles/index.scss"; // 主样式文件
// import 'virtual:svg-icons-register' // SVG图标注册如果使用vite-plugin-svg-icons
// ================== 环境相关配置 ==================
// if (import.meta.env.VITE_MOCK_ENABLED === 'true') {
// mockServer() // 初始化Mock服务
// }
// ================== 全局配置 ==================
app.config.globalProperties.$version = import.meta.env.VITE_APP_VERSION; // 注入版本信息
// ================== 插件安装顺序 ==================
app
.use(pinia) // 优先安装Pinia
.use(router) // 其次安装路由
.use(ElementPlus, {
locale: zhCn,
size: "large", // 全局组件尺寸
zIndex: 3000, // 全局z-index
});
// ================== 全局注册 ==================
// registerGlobalDirectives(app) // 注册自定义指令如权限指令v-permission
// registerGlobalComponents(app) // 注册全局组件(如有)
// ================== 错误处理 ==================
registerErrorHandler(app); // 注册全局错误处理
// ================== 大屏适配初始化 ==================
if (import.meta.env.MODE === "development") {
// 开发环境显示适配基准线
import("@/utils/screen-helper").then(({ showDesignHelper }) => {
showDesignHelper(1920, 1080); // 根据设计稿尺寸显示辅助线
});
}
// ================== 挂载主应用 ==================
app.mount("#app");
// ================== 生产环境性能监控 ==================
// if (import.meta.env.PROD) {
// import('@/utils/performance').then(({ initPerformance }) => {
// initPerformance()
// })
// }