feat: 添加echarts

This commit is contained in:
Bunny 2025-02-26 22:38:06 +08:00
parent 380a1e4f5a
commit 254b795e2e
3 changed files with 49 additions and 1 deletions

View File

@ -9,4 +9,6 @@ import plugins from '@/plugins';
import App from './App.vue';
createApp(App).use(plugins).mount('#app');
const app = createApp(App);
app.use(plugins).mount('#app');

44
src/plugins/echarts.ts Normal file
View File

@ -0,0 +1,44 @@
import { BarChart, LineChart, PieChart } from 'echarts/charts';
import {
DataZoomComponent,
GraphicComponent,
GridComponent,
LegendComponent,
PolarComponent,
TitleComponent,
ToolboxComponent,
TooltipComponent,
VisualMapComponent,
} from 'echarts/components';
import * as echarts from 'echarts/core';
import { CanvasRenderer, SVGRenderer } from 'echarts/renderers';
import type { App } from 'vue';
const { use } = echarts;
use([
PieChart,
BarChart,
LineChart,
CanvasRenderer,
SVGRenderer,
GridComponent,
TitleComponent,
PolarComponent,
LegendComponent,
GraphicComponent,
ToolboxComponent,
TooltipComponent,
DataZoomComponent,
VisualMapComponent,
]);
/**
* @description echarts https://echarts.apache.org/handbook/zh/basics/import/#%E5%9C%A8-typescript-%E4%B8%AD%E6%8C%89%E9%9C%80%E5%BC%95%E5%85%A5
* @see `$echarts` `globalProperties` https://pure-admin-utils.netlify.app/hooks/useECharts/useECharts#%E4%BD%BF%E7%94%A8%E5%89%8D%E6%8F%90
*/
export function useEcharts(app: App) {
app.config.globalProperties.$echarts = echarts;
}
export default echarts;

View File

@ -12,5 +12,7 @@ export default {
setupStore(app);
// 设置指令
setupDirective(app);
// 根据需求引入echarts
// useEcharts(app);
},
};