Merge pull request #11282 from allenve/fix-globalEvent-bug

fix: 全局事件动作避免死锁
This commit is contained in:
Allen 2024-11-28 15:20:16 +08:00 committed by GitHub
commit 311bb4de06
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View File

@ -225,8 +225,12 @@ export const bindGlobalEventForRenderer = (renderer: any) => {
scoped: renderer?.context, scoped: renderer?.context,
data data
}); });
// 过滤掉当前的广播事件,避免循环广播
const actions = listener.actions.filter(
a => !(a.actionType === 'broadcast' && a.eventName === eventName)
);
runActions(listener.actions, renderer, rendererEvent); runActions(actions, renderer, rendererEvent);
}; };
} }
return () => { return () => {

View File

@ -46,7 +46,7 @@ export default class ActionConfigPanel extends React.Component<RendererProps> {
} else { } else {
const __originActionSchema = data.__actionSchema; const __originActionSchema = data.__actionSchema;
schema = isFunction(__originActionSchema) schema = isFunction(__originActionSchema)
? __originActionSchema(manager) ? __originActionSchema(manager, data)
: __originActionSchema; : __originActionSchema;
} }

View File

@ -20,7 +20,7 @@ registerActionPanel('broadcast', {
</div> </div>
); );
}, },
schema: (manager: EditorManager) => { schema: (manager: EditorManager, data: any) => {
const globalEvents = const globalEvents =
manager.config?.actionOptions?.globalEventGetter?.(manager) || []; manager.config?.actionOptions?.globalEventGetter?.(manager) || [];
return { return {
@ -34,7 +34,8 @@ registerActionPanel('broadcast', {
options: globalEvents.map(item => ({ options: globalEvents.map(item => ({
label: item.label, label: item.label,
value: item.name, value: item.name,
mapping: item.mapping mapping: item.mapping,
disabled: item.name === data.eventKey
})), })),
size: 'lg', size: 'lg',
mode: 'horizontal', mode: 'horizontal',