Skip to content

Commit

Permalink
feat(projects): 添加插件页面:图表
Browse files Browse the repository at this point in the history
ISSUES CLOSED: \
  • Loading branch information
honghuangdc committed May 29, 2022
1 parent 39854a4 commit 0a46ea0
Show file tree
Hide file tree
Showing 8 changed files with 449 additions and 143 deletions.
82 changes: 82 additions & 0 deletions mock/model/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,47 @@ export const routeModel: Record<Auth.RoleType, AuthRoute.Route[]> = {
requiresAuth: true,
icon: 'ic:baseline-local-printshop'
}
},
{
name: 'plugin_charts',
path: '/plugin/charts',
component: 'multi',
children: [
{
name: 'plugin_charts_echarts',
path: '/plugin/charts/echarts',
component: 'self',
meta: {
title: 'ECharts',
requiresAuth: true,
icon: 'simple-icons:apacheecharts'
}
},
{
name: 'plugin_charts_d3',
path: '/plugin/charts/d3',
component: 'self',
meta: {
title: 'D3',
requiresAuth: true,
icon: 'simple-icons:d3dotjs'
}
},
{
name: 'plugin_charts_antv',
path: '/plugin/charts/antv',
component: 'self',
meta: {
title: 'AntV',
requiresAuth: true,
icon: 'ant-design:bar-chart-outlined'
}
}
],
meta: {
title: '图表',
icon: 'material-symbols:bar-chart-rounded'
}
}
],
meta: {
Expand Down Expand Up @@ -592,6 +633,47 @@ export const routeModel: Record<Auth.RoleType, AuthRoute.Route[]> = {
requiresAuth: true,
icon: 'ic:baseline-local-printshop'
}
},
{
name: 'plugin_charts',
path: '/plugin/charts',
component: 'multi',
children: [
{
name: 'plugin_charts_echarts',
path: '/plugin/charts/echarts',
component: 'self',
meta: {
title: 'ECharts',
requiresAuth: true,
icon: 'simple-icons:apacheecharts'
}
},
{
name: 'plugin_charts_d3',
path: '/plugin/charts/d3',
component: 'self',
meta: {
title: 'D3',
requiresAuth: true,
icon: 'simple-icons:d3dotjs'
}
},
{
name: 'plugin_charts_antv',
path: '/plugin/charts/antv',
component: 'self',
meta: {
title: 'AntV',
requiresAuth: true,
icon: 'ant-design:bar-chart-outlined'
}
}
],
meta: {
title: '图表',
icon: 'material-symbols:bar-chart-rounded'
}
}
],
meta: {
Expand Down
10 changes: 7 additions & 3 deletions src/hooks/business/useEcharts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ref, watch, nextTick, onUnmounted, computed } from 'vue';
import type { Ref, ComputedRef } from 'vue';
import * as echarts from 'echarts/core';
import { BarChart, LineChart, PieChart } from 'echarts/charts';
import type { BarSeriesOption, LineSeriesOption, PieSeriesOption } from 'echarts/charts';
import { BarChart, LineChart, PieChart, ScatterChart } from 'echarts/charts';
import type { BarSeriesOption, LineSeriesOption, PieSeriesOption, ScatterSeriesOption } from 'echarts/charts';
import {
TitleComponent,
LegendComponent,
Expand All @@ -28,6 +28,7 @@ export type ECOption = echarts.ComposeOption<
| BarSeriesOption
| LineSeriesOption
| PieSeriesOption
| ScatterSeriesOption
| TitleComponentOption
| LegendComponentOption
| TooltipComponentOption
Expand All @@ -47,6 +48,7 @@ echarts.use([
BarChart,
LineChart,
PieChart,
ScatterChart,
LabelLayout,
UniversalTransition,
CanvasRenderer
Expand All @@ -55,7 +57,9 @@ echarts.use([
/**
* Echarts hooks函数
* @param options - 图表配置
* @param renderFun - 图表函数(例如:图表监听函数)
* @param darkMode - 暗黑模式
* @param renderFun - 图表渲染函数(例如:图表监听函数)
* @description 按需引入图表组件,没注册的组件需要先引入
*/
export default function useEcharts(
options: Ref<ECOption> | ComputedRef<ECOption>,
Expand Down
43 changes: 43 additions & 0 deletions src/router/modules/charts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const charts: AuthRoute.Route = {
name: 'plugin_charts',
path: '/plugin/charts',
component: 'multi',
children: [
{
name: 'plugin_charts_echarts',
path: '/plugin/charts/echarts',
component: 'self',
meta: {
title: 'ECharts',
requiresAuth: true,
icon: 'simple-icons:apacheecharts'
}
},
{
name: 'plugin_charts_d3',
path: '/plugin/charts/d3',
component: 'self',
meta: {
title: 'D3',
requiresAuth: true,
icon: 'simple-icons:d3dotjs'
}
},
{
name: 'plugin_charts_antv',
path: '/plugin/charts/antv',
component: 'self',
meta: {
title: 'AntV',
requiresAuth: true,
icon: 'ant-design:bar-chart-outlined'
}
}
],
meta: {
title: '图表',
icon: 'material-symbols:bar-chart-rounded'
}
};

export default charts;
4 changes: 4 additions & 0 deletions src/typings/route.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ declare namespace AuthRoute {
| 'plugin_icon'
| 'plugin_print'
| 'plugin_swiper'
| 'plugin_charts'
| 'plugin_charts_echarts'
| 'plugin_charts_d3'
| 'plugin_charts_antv'
| 'auth-demo'
| 'auth-demo_permission'
| 'auth-demo_super'
Expand Down
Loading

1 comment on commit 0a46ea0

@vercel
Copy link

@vercel vercel bot commented on 0a46ea0 May 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.