Merge pull request #5876 from zhaojianhui-a/master

feat: 组件可见性、可用性动作支持表达式
This commit is contained in:
hsm-lv 2022-12-05 17:28:38 +08:00 committed by GitHub
commit 964e39e72f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,9 +12,11 @@ export interface ICmptAction extends ListenerAction {
| 'static'
| 'nonstatic'
| 'show'
| 'visibility'
| 'hidden'
| 'enabled'
| 'disabled'
| 'usability'
| 'reload';
args: {
value?: string | {[key: string]: string};
@ -46,20 +48,24 @@ export class CmptAction implements RendererAction {
const dataMergeMode = action.dataMergeMode || 'merge';
// 显隐&状态控制
if (['show', 'hidden'].includes(action.actionType)) {
if (['show', 'hidden','visibility'].includes(action.actionType)) {
let visibility = action.actionType === 'visibility'
? action.args?.value : action.actionType === 'show';
return renderer.props.topStore.setVisible(
action.componentId,
action.actionType === 'show'
visibility
);
} else if (['static', 'nonstatic'].includes(action.actionType)) {
return renderer.props.topStore.setStatic(
action.componentId,
action.actionType === 'static'
);
} else if (['enabled', 'disabled'].includes(action.actionType)) {
} else if (['enabled', 'disabled', 'usability'].includes(action.actionType)) {
let usability = action.actionType === 'usability'
? !action.args?.value : action.actionType === 'disabled';
return renderer.props.topStore.setDisable(
action.componentId,
action.actionType === 'disabled'
usability
);
}