From b12a9760c9419b1ec065679b4853fc968941f98d Mon Sep 17 00:00:00 2001 From: allenve Date: Thu, 28 Nov 2024 14:29:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=A8=E5=B1=80=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=8A=A8=E4=BD=9C=E9=81=BF=E5=85=8D=E6=AD=BB=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis-core/src/utils/renderer-event.ts | 6 +++++- .../src/renderer/event-control/action-config-panel.tsx | 2 +- .../actionsPanelPlugins/otherActionsPanel/broadcast.tsx | 5 +++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/amis-core/src/utils/renderer-event.ts b/packages/amis-core/src/utils/renderer-event.ts index f0618167a..ac30b801f 100644 --- a/packages/amis-core/src/utils/renderer-event.ts +++ b/packages/amis-core/src/utils/renderer-event.ts @@ -225,8 +225,12 @@ export const bindGlobalEventForRenderer = (renderer: any) => { scoped: renderer?.context, data }); + // 过滤掉当前的广播事件,避免循环广播 + const actions = listener.actions.filter( + a => !(a.actionType === 'broadcast' && a.eventName === eventName) + ); - runActions(listener.actions, renderer, rendererEvent); + runActions(actions, renderer, rendererEvent); }; } return () => { diff --git a/packages/amis-editor/src/renderer/event-control/action-config-panel.tsx b/packages/amis-editor/src/renderer/event-control/action-config-panel.tsx index 8a10fd208..bfaeeda2e 100644 --- a/packages/amis-editor/src/renderer/event-control/action-config-panel.tsx +++ b/packages/amis-editor/src/renderer/event-control/action-config-panel.tsx @@ -46,7 +46,7 @@ export default class ActionConfigPanel extends React.Component { } else { const __originActionSchema = data.__actionSchema; schema = isFunction(__originActionSchema) - ? __originActionSchema(manager) + ? __originActionSchema(manager, data) : __originActionSchema; } diff --git a/packages/amis-editor/src/renderer/event-control/actionsPanelPlugins/otherActionsPanel/broadcast.tsx b/packages/amis-editor/src/renderer/event-control/actionsPanelPlugins/otherActionsPanel/broadcast.tsx index 8a9dd61c8..3a07eb08e 100644 --- a/packages/amis-editor/src/renderer/event-control/actionsPanelPlugins/otherActionsPanel/broadcast.tsx +++ b/packages/amis-editor/src/renderer/event-control/actionsPanelPlugins/otherActionsPanel/broadcast.tsx @@ -20,7 +20,7 @@ registerActionPanel('broadcast', { ); }, - schema: (manager: EditorManager) => { + schema: (manager: EditorManager, data: any) => { const globalEvents = manager.config?.actionOptions?.globalEventGetter?.(manager) || []; return { @@ -34,7 +34,8 @@ registerActionPanel('broadcast', { options: globalEvents.map(item => ({ label: item.label, value: item.name, - mapping: item.mapping + mapping: item.mapping, + disabled: item.name === data.eventKey })), size: 'lg', mode: 'horizontal',