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

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