From 53c4763a596abfb355061db651dc56843e75cacc Mon Sep 17 00:00:00 2001 From: roymondchen Date: Fri, 7 Aug 2026 17:01:52 +0800 Subject: [PATCH] =?UTF-8?q?fix(editor):=20=E8=8A=82=E7=82=B9=E6=9C=AA?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E6=97=B6=E5=9B=9E=E9=80=80=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=20formValue=20=E5=8A=A0=E8=BD=BD=E4=BA=8B=E4=BB=B6=E4=B8=8E?= =?UTF-8?q?=E5=8A=A8=E4=BD=9C=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当 editorService.getNodeById 找不到节点时,使用 formValue 作为 fallback,避免事件名和动作选项为空。 --- packages/editor/src/fields/EventSelect.vue | 6 +++--- packages/editor/src/utils/event.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/editor/src/fields/EventSelect.vue b/packages/editor/src/fields/EventSelect.vue index 8ab8bd95..a19e63e9 100644 --- a/packages/editor/src/fields/EventSelect.vue +++ b/packages/editor/src/fields/EventSelect.vue @@ -85,7 +85,7 @@ import { Delete } from '@element-plus/icons-vue'; import { Plus } from '@element-plus/icons-vue'; import { has } from 'lodash-es'; -import { ActionType } from '@tmagic/core'; +import { ActionType, MNode } from '@tmagic/core'; import { TMagicButton } from '@tmagic/design'; import type { CodeSelectColConfig, @@ -327,8 +327,8 @@ const tableConfig = computed( name: 'method', label: '动作', type: compActionConfig.value.type, - options: (mForm: FormState, { model }: any) => { - const node = editorService.getNodeById(model.to); + options: (mForm: FormState, { model, formValue }: any) => { + const node = editorService.getNodeById(model.to) || (formValue as MNode); if (!node?.type) return []; return eventsService.getMethod(node.type, { targetId: model.to, node }).map((option: any) => ({ diff --git a/packages/editor/src/utils/event.ts b/packages/editor/src/utils/event.ts index 4725a547..285b928e 100644 --- a/packages/editor/src/utils/event.ts +++ b/packages/editor/src/utils/event.ts @@ -16,7 +16,7 @@ * limitations under the License. */ -import type { EventOption, Id, MComponent, MContainer } from '@tmagic/core'; +import type { EventOption, Id, MComponent, MContainer, MNode } from '@tmagic/core'; import type { CascaderOption } from '@tmagic/form'; import { DATA_SOURCE_FIELDS_CHANGE_EVENT_PREFIX, traverseNode } from '@tmagic/utils'; @@ -56,7 +56,7 @@ export const getEventNameOptions = ( } if (src === 'component') { - const sourceNode = editorService.getNodeById(formValue.id); + const sourceNode = editorService.getNodeById(formValue.id) || (formValue as MNode); let events: EventOption[] | CascaderOption[] = eventsService.getEvent(formValue.type, { node: sourceNode }) || []; if (formValue.type === 'page-fragment-container' && formValue.pageFragmentId) {