-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11253 from allenve/fix-globalEventPanel
fix: 全局广播事件配置面板
- Loading branch information
Showing
3 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
...mis-editor/src/renderer/event-control/actionsPanelPlugins/otherActionsPanel/broadcast.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React from 'react'; | ||
import {registerActionPanel} from '../../actionsPanelManager'; | ||
import {getSchemaTpl, EditorManager} from 'amis-editor-core'; | ||
|
||
registerActionPanel('broadcast', { | ||
label: '全局广播事件', | ||
tag: '其他', | ||
description: '触发全局广播事件', | ||
innerArgs: [], | ||
descDetail: (info: any, context: any, props: any) => { | ||
const globalEvents = props.globalEvents || []; | ||
const event = globalEvents.find( | ||
(item: any) => item.name === info?.eventName | ||
); | ||
return ( | ||
<div> | ||
触发 | ||
<span className="ml-1 mr-1">{event?.label || info?.eventName}</span> | ||
全局广播事件 | ||
</div> | ||
); | ||
}, | ||
schema: (manager: EditorManager) => { | ||
const globalEvents = | ||
manager.config?.actionOptions?.globalEventGetter?.(manager) || []; | ||
return { | ||
type: 'wrapper', | ||
body: [ | ||
{ | ||
type: 'select', | ||
name: 'eventName', | ||
required: true, | ||
label: '请选择全局事件', | ||
options: globalEvents.map(item => ({ | ||
label: item.label, | ||
value: item.name, | ||
mapping: item.mapping | ||
})), | ||
size: 'lg', | ||
mode: 'horizontal', | ||
initAutoFill: true, | ||
autoFill: { | ||
__mapping: '${mapping}' | ||
}, | ||
onChange: async (val: any, oldVal: any, props: any, form: any) => { | ||
form.setValueByName('data', void 0); | ||
} | ||
}, | ||
{ | ||
type: 'input-kv', | ||
name: 'data', | ||
label: '参数映射', | ||
mode: 'horizontal', | ||
draggable: false, | ||
visibleOn: 'this.eventName', | ||
keySchema: { | ||
type: 'select', | ||
label: false, | ||
name: 'key', | ||
source: '${ARRAYMAP(__mapping, i => i.key)}' | ||
}, | ||
valueSchema: getSchemaTpl('tplFormulaControl', { | ||
label: false, | ||
name: 'value', | ||
clearable: true, | ||
placeholder: '请输入参数值', | ||
variables: '${variables}', | ||
header: '配置参数值' | ||
}) | ||
} | ||
] | ||
}; | ||
} | ||
}); |
1 change: 1 addition & 0 deletions
1
...ges/amis-editor/src/renderer/event-control/actionsPanelPlugins/otherActionsPanel/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
import './copy'; | ||
import './custom'; | ||
import './broadcast'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters