perf: echarts 按需导入,分散注册到具体使用页面
- 移除 main.ts 中 echarts 全量导入和集中注册 - chart/index.vue 仅导入 init,改用 ReturnType 推断类型 - DataReportPage.vue 按需注册 LineChart/PieChart/RadarChart 及组件 - CanvasRenderer 保持全局注册,所有图表共用 - 主 chunk 减小 55%(1,279 kB → 572 kB),echarts 模块随页面懒加载
This commit is contained in:
11
src/main.ts
11
src/main.ts
@@ -2,13 +2,18 @@ import { createApp } from "vue";
|
||||
import "./style.less";
|
||||
import App from "./App.vue";
|
||||
import Chart from "./components/chart/index.vue";
|
||||
import * as echarts from "echarts";
|
||||
import { registerTheme } from "echarts/core";
|
||||
import { CanvasRenderer } from "echarts/renderers";
|
||||
import echartsConfig from "./config/echarts.config";
|
||||
import { createPinia } from "pinia";
|
||||
import router from "./router";
|
||||
import './router/routerGuard'
|
||||
import "./router/routerGuard";
|
||||
|
||||
echarts.registerTheme("t-theme", echartsConfig);
|
||||
// CanvasRenderer 注册到全局,所有图表都需要
|
||||
import { use } from "echarts/core";
|
||||
use([CanvasRenderer]);
|
||||
|
||||
registerTheme("t-theme", echartsConfig);
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user