- echarts.ts: 将 EChartsOption 改为 EChartsCoreOption 的类型别名 - FuiCorners: 移除 extends BoxProps,position 重命名为 corner - KLineChartModal/TimelineChartModal/ConcentrationCard: 使用导入的 EChartsOption - LoadingState: 新增骨架屏 variant 支持 - FinancialPanorama: 使用骨架屏加载状态 - useFinancialData/financialService: 优化数据获取逻辑 - Company/index: 简化组件结构 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
125 lines
2.5 KiB
TypeScript
125 lines
2.5 KiB
TypeScript
/**
|
||
* ECharts 按需导入配置
|
||
*
|
||
* 使用方式:
|
||
* import { echarts } from '@lib/echarts';
|
||
*
|
||
* 优势:
|
||
* - 减小打包体积(从 ~800KB 降至 ~200-300KB)
|
||
* - Tree-shaking 支持
|
||
* - 统一管理图表类型和组件
|
||
*/
|
||
|
||
// 核心模块
|
||
import * as echarts from 'echarts/core';
|
||
|
||
// 图表类型 - 按需导入
|
||
import {
|
||
LineChart,
|
||
BarChart,
|
||
PieChart,
|
||
CandlestickChart,
|
||
ScatterChart,
|
||
} from 'echarts/charts';
|
||
|
||
// 组件 - 按需导入
|
||
import {
|
||
TitleComponent,
|
||
TooltipComponent,
|
||
LegendComponent,
|
||
GridComponent,
|
||
DataZoomComponent,
|
||
ToolboxComponent,
|
||
MarkLineComponent,
|
||
MarkPointComponent,
|
||
MarkAreaComponent,
|
||
DatasetComponent,
|
||
TransformComponent,
|
||
} from 'echarts/components';
|
||
|
||
// 渲染器
|
||
import { CanvasRenderer } from 'echarts/renderers';
|
||
|
||
// 类型导出
|
||
import type {
|
||
ECharts,
|
||
EChartsCoreOption,
|
||
SetOptionOpts,
|
||
ComposeOption,
|
||
} from 'echarts/core';
|
||
|
||
import type {
|
||
LineSeriesOption,
|
||
BarSeriesOption,
|
||
PieSeriesOption,
|
||
CandlestickSeriesOption,
|
||
ScatterSeriesOption,
|
||
} from 'echarts/charts';
|
||
|
||
import type {
|
||
TitleComponentOption,
|
||
TooltipComponentOption,
|
||
LegendComponentOption,
|
||
GridComponentOption,
|
||
DataZoomComponentOption,
|
||
ToolboxComponentOption,
|
||
MarkLineComponentOption,
|
||
MarkPointComponentOption,
|
||
MarkAreaComponentOption,
|
||
DatasetComponentOption,
|
||
} from 'echarts/components';
|
||
|
||
// 注册必需的组件
|
||
echarts.use([
|
||
// 图表类型
|
||
LineChart,
|
||
BarChart,
|
||
PieChart,
|
||
CandlestickChart,
|
||
ScatterChart,
|
||
// 组件
|
||
TitleComponent,
|
||
TooltipComponent,
|
||
LegendComponent,
|
||
GridComponent,
|
||
DataZoomComponent,
|
||
ToolboxComponent,
|
||
MarkLineComponent,
|
||
MarkPointComponent,
|
||
MarkAreaComponent,
|
||
DatasetComponent,
|
||
TransformComponent,
|
||
// 渲染器
|
||
CanvasRenderer,
|
||
]);
|
||
|
||
// 组合类型定义(用于 TypeScript 类型推断)
|
||
export type ECOption = ComposeOption<
|
||
| LineSeriesOption
|
||
| BarSeriesOption
|
||
| PieSeriesOption
|
||
| CandlestickSeriesOption
|
||
| ScatterSeriesOption
|
||
| TitleComponentOption
|
||
| TooltipComponentOption
|
||
| LegendComponentOption
|
||
| GridComponentOption
|
||
| DataZoomComponentOption
|
||
| ToolboxComponentOption
|
||
| MarkLineComponentOption
|
||
| MarkPointComponentOption
|
||
| MarkAreaComponentOption
|
||
| DatasetComponentOption
|
||
>;
|
||
|
||
// 导出
|
||
export { echarts };
|
||
|
||
// EChartsOption 类型别名(兼容旧代码)
|
||
export type EChartsOption = EChartsCoreOption;
|
||
|
||
export type { ECharts, SetOptionOpts };
|
||
|
||
// 默认导出(兼容 import * as echarts from 'echarts' 的用法)
|
||
export default echarts;
|