feat: enhance ViewActionModel with customizable open options and improved event handling

This commit is contained in:
Zeke Zhang 2025-06-19 07:05:54 +08:00
parent 71723be793
commit 88ba482a9d

View File

@ -20,12 +20,43 @@ export class ViewActionModel extends ActionModel {
} }
ViewActionModel.registerFlow({ ViewActionModel.registerFlow({
key: 'event1', key: 'handleClick',
title: '点击事件',
on: { on: {
eventName: 'click', eventName: 'click',
}, },
steps: { steps: {
step1: { open: {
title: '打开方式',
uiSchema: {
mode: {
type: 'string',
title: '打开方式',
enum: [
{ label: 'Drawer', value: 'drawer' },
{ label: 'Modal', value: 'modal' },
],
'x-decorator': 'FormItem',
'x-component': 'Radio.Group',
},
size: {
type: 'string',
title: '弹窗尺寸',
enum: [
{ label: '小', value: 'small' },
{ label: '中', value: 'medium' },
{ label: '大', value: 'large' },
],
'x-decorator': 'FormItem',
'x-component': 'Radio.Group',
},
},
defaultParams(ctx) {
return {
mode: 'drawer',
size: 'medium',
};
},
handler(ctx, params) { handler(ctx, params) {
// eslint-disable-next-line prefer-const // eslint-disable-next-line prefer-const
let currentDrawer: any; let currentDrawer: any;
@ -38,9 +69,15 @@ ViewActionModel.registerFlow({
); );
} }
currentDrawer = ctx.globals.drawer.open({ const sizeToWidthMap: Record<string, number> = {
small: 480,
medium: 800,
large: 1200,
};
currentDrawer = ctx.globals[params.mode].open({
title: '命令式 Drawer', title: '命令式 Drawer',
width: 800, width: sizeToWidthMap[params.size],
content: <DrawerContent />, content: <DrawerContent />,
}); });
}, },