From 605f07c8fe24fd67de22f5cb9adfdb151d3b8772 Mon Sep 17 00:00:00 2001 From: roymondchen Date: Mon, 6 Jul 2026 17:17:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(editor):=20=E6=94=AF=E6=8C=81=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=8E=86=E5=8F=B2=E5=AF=B9=E6=AF=94/?= =?UTF-8?q?=E5=9B=9E=E6=BB=9A=E5=BC=B9=E7=AA=97=E5=86=85=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E7=9A=84=E5=B0=BA=E5=AF=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/editor/src/components/CompareForm.vue | 7 +++++++ .../src/layouts/history-list/HistoryDiffDialog.vue | 12 +++++++++++- .../src/layouts/history-list/useHistoryRevert.ts | 4 ++++ packages/editor/src/type.ts | 6 ++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/editor/src/components/CompareForm.vue b/packages/editor/src/components/CompareForm.vue index 56569926..d825c014 100644 --- a/packages/editor/src/components/CompareForm.vue +++ b/packages/editor/src/components/CompareForm.vue @@ -13,6 +13,7 @@ :extend-state="mergedExtendState" :show-diff="showDiff" :self-diff-field-types="selfDiffFieldTypes" + :size="size" > @@ -22,6 +23,7 @@ import { computed, inject, provide, type Ref, ref, type ShallowRef, useTemplateR import { isEqual } from 'lodash-es'; import { type CodeBlockContent, type DataSourceSchema, HookType, type MNode } from '@tmagic/core'; +import { type FieldSize } from '@tmagic/design'; import { type FormConfig, type FormState, type FormValue, MForm } from '@tmagic/form'; import type { CompareCategory, CompareFormLoadConfig, Services } from '@editor/type'; @@ -68,6 +70,11 @@ const props = withDefaults( baseFormState?: FormState; /** 需要走 self diff 的字段类型(例如 mod-cond)。 */ selfDiffFieldTypes?: string[]; + /** + * 表单内组件的尺寸(透传给 MForm 的 `size`),可选 'large' | 'default' | 'small'。 + * 缺省时使用 MForm 内置默认尺寸。 + */ + size?: FieldSize; /** * 自定义 FormConfig 加载逻辑。传入后将接管内置的按 `category`(node/data-source/code-block) * 取配置逻辑,调用方可根据业务自行返回(或异步返回)表单配置。可通过 diff --git a/packages/editor/src/layouts/history-list/HistoryDiffDialog.vue b/packages/editor/src/layouts/history-list/HistoryDiffDialog.vue index c2b38fbf..8d89ae45 100644 --- a/packages/editor/src/layouts/history-list/HistoryDiffDialog.vue +++ b/packages/editor/src/layouts/history-list/HistoryDiffDialog.vue @@ -48,6 +48,7 @@ :load-config="loadConfig" :self-diff-field-types="selfDiffFieldTypes" :services="props.services" + :size="props.size" height="70vh" /> @@ -77,7 +78,14 @@ import { computed, ref, watch } from 'vue'; import { isEqual } from 'lodash-es'; -import { TMagicButton, TMagicDialog, TMagicRadioButton, TMagicRadioGroup, TMagicTag } from '@tmagic/design'; +import { + type FieldSize, + TMagicButton, + TMagicDialog, + TMagicRadioButton, + TMagicRadioGroup, + TMagicTag, +} from '@tmagic/design'; import type { FormState } from '@tmagic/form'; import CompareForm from '@editor/components/CompareForm.vue'; @@ -104,6 +112,8 @@ const props = withDefaults( */ loadConfig?: CompareFormLoadConfig; width?: string; + /** 差异对比表单内组件的尺寸(透传给 CompareForm 的 `size`),可选 'large' | 'default' | 'small'。 */ + size?: FieldSize; isConfirm?: boolean; onConfirm?: () => void; selfDiffFieldTypes?: string[]; diff --git a/packages/editor/src/layouts/history-list/useHistoryRevert.ts b/packages/editor/src/layouts/history-list/useHistoryRevert.ts index 6c241298..fffbb13e 100644 --- a/packages/editor/src/layouts/history-list/useHistoryRevert.ts +++ b/packages/editor/src/layouts/history-list/useHistoryRevert.ts @@ -95,6 +95,7 @@ const mountHistoryDiffDialog = async ( selfDiffFieldTypes: options.selfDiffFieldTypes, compareFormState: options.compareFormState, width: options.width, + size: options.size ?? options.services?.uiService?.get('propsPanelSize'), onClose: options.onClose, }); if (options.appContext) { @@ -223,6 +224,7 @@ export const useHistoryRevert = (options: UseHistoryRevertOptions = {}, services services, ...extra, width: extra?.width ?? dialogWidth, + size: extra?.size, }); } return confirmRevert(); @@ -382,6 +384,7 @@ export const useHistoryRevert = (options: UseHistoryRevertOptions = {}, services loadConfig: revertOptions.loadConfig, selfDiffFieldTypes: revertOptions.selfDiffFieldTypes, width: revertOptions.width, + size: revertOptions.size, }); if (!confirmed) return null; return await revertOptions.revert(); @@ -399,6 +402,7 @@ export const useHistoryRevert = (options: UseHistoryRevertOptions = {}, services services, ...extra, width: extra?.width ?? dialogWidth, + size: extra?.size, }); }; diff --git a/packages/editor/src/type.ts b/packages/editor/src/type.ts index 38e7263d..0d302bd7 100644 --- a/packages/editor/src/type.ts +++ b/packages/editor/src/type.ts @@ -33,6 +33,7 @@ import type { MPage, MPageFragment, } from '@tmagic/core'; +import type { FieldSize } from '@tmagic/design'; import type { ChangeRecord, FormConfig, FormState, TableColumnConfig, TypeFunction } from '@tmagic/form'; import type StageCore from '@tmagic/stage'; import type { @@ -1453,6 +1454,11 @@ export interface CustomDiffFormOptions { * 如 `'1200px'` / `'80%'`。缺省时使用弹窗内置默认宽度(900px)。 */ width?: string; + /** + * 差异 / 确认回滚弹窗内 form 表单的尺寸(透传给 CompareForm 的 `size`), + * 可选 `'large' | 'default' | 'small'`,缺省时使用表单内置默认尺寸。 + */ + size?: FieldSize; } /**