From 6f95fb6db619df5e9084a5d5fa7b3ffdfaf4cb89 Mon Sep 17 00:00:00 2001 From: hsm-lv Date: Fri, 29 Apr 2022 18:15:33 +0800 Subject: [PATCH] =?UTF-8?q?docs:=E4=BF=AE=E5=A4=8Ddemo=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/zh-CN/concepts/event-action.md | 18 +++++++--- src/actions/Action.ts | 54 ++++++++++++++++------------- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/docs/zh-CN/concepts/event-action.md b/docs/zh-CN/concepts/event-action.md index c52abad04..f5638e9b5 100644 --- a/docs/zh-CN/concepts/event-action.md +++ b/docs/zh-CN/concepts/event-action.md @@ -195,7 +195,9 @@ order: 9 actions: [ { actionType: 'toast', - msg: 'confirm' + args: { + msg: 'confirm' + } } ] }, @@ -203,7 +205,9 @@ order: 9 actions: [ { actionType: 'toast', - msg: 'cancel' + args: { + msg: 'cancel' + } } ] } @@ -346,7 +350,9 @@ order: 9 actions: [ { actionType: 'toast', - msg: 'confirm' + args: { + msg: 'confirm' + } } ] }, @@ -354,7 +360,9 @@ order: 9 actions: [ { actionType: 'toast', - msg: 'cancel' + args: { + msg: 'cancel' + } } ] } @@ -2382,7 +2390,7 @@ order: 9 actionType: 'changeActiveKey', componentId: 'tabs-change-receiver', args: { - activeKey: 1 + activeKey: 2 } } ] diff --git a/src/actions/Action.ts b/src/actions/Action.ts index 59df47b58..948693b51 100644 --- a/src/actions/Action.ts +++ b/src/actions/Action.ts @@ -1,25 +1,29 @@ -import { RendererProps } from '../factory'; -import { extendObject } from '../utils/helper'; -import { RendererEvent } from '../utils/renderer-event'; -import { evalExpression } from '../utils/tpl'; -import { dataMapping } from '../utils/tpl-builtin'; -import { IAjaxAction } from './AjaxAction'; -import { IBreakAction } from './BreakAction'; -import { IBroadcastAction } from './BroadcastAction'; -import { ICmptAction } from './CmptAction'; -import { IContinueAction } from './ContinueAction'; -import { ICopyAction } from './CopyAction'; -import { ICustomAction } from './CustomAction'; -import { IAlertAction, IConfirmAction, IDialogAction, ICloseDialogAction } from './DialogAction'; -import { IDrawerAction, ICloseDrawerAction } from './DrawerAction'; -import { IEmailAction } from './EmailAction'; -import { ILinkAction } from './LinkAction'; -import { ILoopAction } from './LoopAction'; -import { IPageGoAction } from './PageAction'; -import { IParallelAction } from './ParallelAction'; -import { ISwitchAction } from './SwitchAction'; -import { IToastAction } from './ToastAction'; - +import {RendererProps} from '../factory'; +import {extendObject} from '../utils/helper'; +import {RendererEvent} from '../utils/renderer-event'; +import {evalExpression} from '../utils/tpl'; +import {dataMapping} from '../utils/tpl-builtin'; +import {IAjaxAction} from './AjaxAction'; +import {IBreakAction} from './BreakAction'; +import {IBroadcastAction} from './BroadcastAction'; +import {ICmptAction} from './CmptAction'; +import {IContinueAction} from './ContinueAction'; +import {ICopyAction} from './CopyAction'; +import {ICustomAction} from './CustomAction'; +import { + IAlertAction, + IConfirmAction, + IDialogAction, + ICloseDialogAction +} from './DialogAction'; +import {IDrawerAction, ICloseDrawerAction} from './DrawerAction'; +import {IEmailAction} from './EmailAction'; +import {ILinkAction} from './LinkAction'; +import {ILoopAction} from './LoopAction'; +import {IPageGoAction} from './PageAction'; +import {IParallelAction} from './ParallelAction'; +import {ISwitchAction} from './SwitchAction'; +import {IToastAction} from './ToastAction'; // 循环动作执行状态 export enum LoopStatus { @@ -87,7 +91,7 @@ export interface RendererAction { } // 存储 Action 和类型的映射关系,用于后续查找 -const ActionTypeMap: { [key: string]: RendererAction } = {}; +const ActionTypeMap: {[key: string]: RendererAction} = {}; // 注册 Action export const registerAction = (type: string, action: RendererAction) => { @@ -161,7 +165,9 @@ export const runAction = async ( let args = event.data; if (actionConfig.args) { - args = dataMapping(actionConfig.args, mergeData, (key) => ['adaptor', 'responseAdaptor', 'requestAdaptor'].includes(key)); + args = dataMapping(actionConfig.args, mergeData, key => + ['adaptor', 'responseAdaptor', 'requestAdaptor'].includes(key) + ); } await actionInstrance.run(