From 87d1593a1f52dc06df779e0357cc03124ea5738f Mon Sep 17 00:00:00 2001 From: Jin Mao Date: Wed, 25 Mar 2026 15:16:24 +0800 Subject: [PATCH] =?UTF-8?q?refactor(effects):=20=E6=89=A9=E5=B1=95=20echar?= =?UTF-8?q?ts=20=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=8F=92=E4=BB=B6=E9=85=8D=E7=BD=AE=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 PieSeriesOption 和 RadarSeriesOption 到 echarts 类型定义 - 添加 LegendComponentOption 和 ToolboxComponentOption 组件选项 - 重构 providePluginsOptions 函数实现深合并逻辑 - 优化 vxe-table 初始化中的表单工厂优先级处理 - 调整 playground 中的 import 语句顺序和格式 --- packages/effects/plugins/src/echarts/types.ts | 13 +++++++++- .../effects/plugins/src/plugins-context.ts | 23 +++++++++++++++- .../effects/plugins/src/vxe-table/init.ts | 7 +++-- playground/src/adapter/vxe-table.ts | 26 ++++++++++--------- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/packages/effects/plugins/src/echarts/types.ts b/packages/effects/plugins/src/echarts/types.ts index 9276e0194..56813754d 100644 --- a/packages/effects/plugins/src/echarts/types.ts +++ b/packages/effects/plugins/src/echarts/types.ts @@ -1,9 +1,16 @@ -import type { BarSeriesOption, LineSeriesOption } from 'echarts/charts'; +import type { + BarSeriesOption, + LineSeriesOption, + PieSeriesOption, + RadarSeriesOption, +} from 'echarts/charts'; import type { DatasetComponentOption, GridComponentOption, + LegendComponentOption, TitleComponentOption, TooltipComponentOption, + ToolboxComponentOption, } from 'echarts/components'; import type { ComposeOption } from 'echarts/core'; @@ -11,7 +18,11 @@ export type ECOption = ComposeOption< | BarSeriesOption | DatasetComponentOption | GridComponentOption + | LegendComponentOption | LineSeriesOption + | PieSeriesOption + | RadarSeriesOption | TitleComponentOption | TooltipComponentOption + | ToolboxComponentOption >; diff --git a/packages/effects/plugins/src/plugins-context.ts b/packages/effects/plugins/src/plugins-context.ts index ae8b26717..a8d07e744 100644 --- a/packages/effects/plugins/src/plugins-context.ts +++ b/packages/effects/plugins/src/plugins-context.ts @@ -3,7 +3,28 @@ import type { VbenPluginsOptions } from "./types"; let globalPluginsOptions: VbenPluginsOptions | null = null; export function providePluginsOptions(options: VbenPluginsOptions) { - globalPluginsOptions = options; + if (!globalPluginsOptions) { + globalPluginsOptions = options; + return; + } + + globalPluginsOptions = { + ...globalPluginsOptions, + ...options, + form: globalPluginsOptions.form && options.form + ? { ...globalPluginsOptions.form, ...options.form } + : globalPluginsOptions.form || options.form, + modal: globalPluginsOptions.modal && options.modal + ? { ...globalPluginsOptions.modal, ...options.modal } + : globalPluginsOptions.modal || options.modal, + message: globalPluginsOptions.message && options.message + ? { ...globalPluginsOptions.message, ...options.message } + : globalPluginsOptions.message || options.message, + components: { + ...globalPluginsOptions.components, + ...options.components, + }, + }; } export function injectPluginsOptions() { diff --git a/packages/effects/plugins/src/vxe-table/init.ts b/packages/effects/plugins/src/vxe-table/init.ts index d92136ec6..d0915dd59 100644 --- a/packages/effects/plugins/src/vxe-table/init.ts +++ b/packages/effects/plugins/src/vxe-table/init.ts @@ -21,12 +21,11 @@ import { VxeUI, VxeUpload } from "vxe-pc-ui"; -import enUS from "vxe-pc-ui/lib/language/en-US"; -// 导入默认的语言 +import enUS from "vxe-pc-ui/lib/language/en-US"; // 导入默认的语言 import zhCN from "vxe-pc-ui/lib/language/zh-CN"; import { VxeColgroup, VxeColumn, VxeGrid, VxeTable, VxeToolbar } from "vxe-table"; -import { extendsDefaultFormatter } from "./extends"; +import { extendsDefaultFormatter } from "./extends"; // 是否加载过 // 是否加载过 let isInit = false; @@ -109,7 +108,7 @@ export function setupVbenVxeTable(setupOptions: SetupVxeTable) { initVxeTable(); - // 优先使用参数传入的 useVbenForm,context 注入在 useTableForm 中获取 + // 优先使用参数传入的 useVbenForm,否则清空让 context 注入生效 if (useVbenFormFromParam) { tableFormFactory = useVbenFormFromParam; } diff --git a/playground/src/adapter/vxe-table.ts b/playground/src/adapter/vxe-table.ts index ec5711ebe..07e9a8d1c 100644 --- a/playground/src/adapter/vxe-table.ts +++ b/playground/src/adapter/vxe-table.ts @@ -1,20 +1,22 @@ -import type { VxeTableGridOptions } from "@vben/plugins/vxe-table"; -import { setupVbenVxeTable, useVbenVxeGrid as useGrid } from "@vben/plugins/vxe-table"; -import type { Recordable } from "@vben/types"; +import type { VxeTableGridOptions } from '@vben/plugins/vxe-table'; +import type { Recordable } from '@vben/types'; -import type { ComponentType } from "./component"; +import type { ComponentType } from './component'; -import { h } from "vue"; +import { h } from 'vue'; -import { IconifyIcon } from "@vben/icons"; -import { $te } from "@vben/locales"; -import { get, isFunction, isString } from "@vben/utils"; +import { IconifyIcon } from '@vben/icons'; +import { $te } from '@vben/locales'; +import { + setupVbenVxeTable, + useVbenVxeGrid as useGrid, +} from '@vben/plugins/vxe-table'; +import { get, isFunction, isString } from '@vben/utils'; -import { objectOmit } from "@vueuse/core"; -import { Button, Image, Popconfirm, Switch, Tag } from "ant-design-vue"; +import { objectOmit } from '@vueuse/core'; +import { Button, Image, Popconfirm, Switch, Tag } from 'ant-design-vue'; - -import { $t } from "#/locales"; +import { $t } from '#/locales'; setupVbenVxeTable({ configVxeTable: (vxeUI) => {