mirror of
https://github.com/imdap/ruoyi-plus-vben5.git
synced 2026-04-23 00:38:34 +08:00
refactor: 重构 ECharts 插件类型定义和导出结构
- 将 ECOption 类型定义移至独立的 types.ts 文件 - 修改 echarts.ts 文件导入 ECOption 类型而不是定义 - 更新 index.ts 添加 types 导出 - 移除 echarts.ts 中冗余的类型导入和定义 - 添加完整的 README.md 文档说明插件使用方法 - 优化代码组织结构提高可维护性
This commit is contained in:
41
packages/effects/plugins/src/echarts/README.md
Normal file
41
packages/effects/plugins/src/echarts/README.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# ECharts Plugin
|
||||
|
||||
ECharts 图表插件,预置常用组件和图表类型。
|
||||
|
||||
## 导出
|
||||
|
||||
| 导出 | 类型 | 说明 |
|
||||
| ------------ | ---- | ------------ |
|
||||
| `default` | 对象 | echarts 实例 |
|
||||
| `EchartsUI` | 组件 | 图表容器组件 |
|
||||
| `ECOption` | 类型 | 图表配置类型 |
|
||||
| `useEcharts` | 函数 | 组合式函数 |
|
||||
|
||||
## 使用
|
||||
|
||||
```ts
|
||||
import { EchartsUI, useEcharts, ECOption } from '@vben/plugins/echarts';
|
||||
```
|
||||
|
||||
## 类型
|
||||
|
||||
```ts
|
||||
import type { ECOption } from '@vben/plugins/echarts';
|
||||
```
|
||||
|
||||
## 预置组件
|
||||
|
||||
- TitleComponent
|
||||
- TooltipComponent
|
||||
- GridComponent
|
||||
- LegendComponent
|
||||
- ToolboxComponent
|
||||
- DatasetComponent
|
||||
- TransformComponent
|
||||
|
||||
## 预置图表
|
||||
|
||||
- BarChart
|
||||
- LineChart
|
||||
- PieChart
|
||||
- RadarChart
|
||||
@@ -1,48 +1,20 @@
|
||||
import type {
|
||||
// 系列类型的定义后缀都为 SeriesOption
|
||||
BarSeriesOption,
|
||||
LineSeriesOption,
|
||||
} from 'echarts/charts';
|
||||
import type {
|
||||
DatasetComponentOption,
|
||||
GridComponentOption,
|
||||
// 组件类型的定义后缀都为 ComponentOption
|
||||
TitleComponentOption,
|
||||
TooltipComponentOption,
|
||||
} from 'echarts/components';
|
||||
import type { ComposeOption } from 'echarts/core';
|
||||
export type { ECOption } from './types';
|
||||
|
||||
import { BarChart, LineChart, PieChart, RadarChart } from 'echarts/charts';
|
||||
import { BarChart, LineChart, PieChart, RadarChart } from "echarts/charts";
|
||||
import {
|
||||
// 数据集组件
|
||||
DatasetComponent,
|
||||
GridComponent,
|
||||
LegendComponent,
|
||||
TitleComponent,
|
||||
ToolboxComponent,
|
||||
TooltipComponent,
|
||||
// 内置数据转换器组件 (filter, sort)
|
||||
TransformComponent,
|
||||
} from 'echarts/components';
|
||||
import * as echarts from 'echarts/core';
|
||||
import {
|
||||
LabelLayout,
|
||||
LegacyGridContainLabel,
|
||||
UniversalTransition,
|
||||
} from 'echarts/features';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
TransformComponent
|
||||
} from "echarts/components";
|
||||
import * as echarts from "echarts/core";
|
||||
import { LabelLayout, LegacyGridContainLabel, UniversalTransition } from "echarts/features";
|
||||
import { CanvasRenderer } from "echarts/renderers";
|
||||
|
||||
// 通过 ComposeOption 来组合出一个只有必须组件和图表的 Option 类型
|
||||
export type ECOption = ComposeOption<
|
||||
| BarSeriesOption
|
||||
| DatasetComponentOption
|
||||
| GridComponentOption
|
||||
| LineSeriesOption
|
||||
| TitleComponentOption
|
||||
| TooltipComponentOption
|
||||
>;
|
||||
|
||||
// 注册必须的组件
|
||||
echarts.use([
|
||||
TitleComponent,
|
||||
PieChart,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from './echarts';
|
||||
export * from './types';
|
||||
export { default as EchartsUI } from './echarts-ui.vue';
|
||||
export * from './use-echarts';
|
||||
|
||||
17
packages/effects/plugins/src/echarts/types.ts
Normal file
17
packages/effects/plugins/src/echarts/types.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { BarSeriesOption, LineSeriesOption } from 'echarts/charts';
|
||||
import type {
|
||||
DatasetComponentOption,
|
||||
GridComponentOption,
|
||||
TitleComponentOption,
|
||||
TooltipComponentOption,
|
||||
} from 'echarts/components';
|
||||
import type { ComposeOption } from 'echarts/core';
|
||||
|
||||
export type ECOption = ComposeOption<
|
||||
| BarSeriesOption
|
||||
| DatasetComponentOption
|
||||
| GridComponentOption
|
||||
| LineSeriesOption
|
||||
| TitleComponentOption
|
||||
| TooltipComponentOption
|
||||
>;
|
||||
Reference in New Issue
Block a user