fix"修复ts声明导致的schema构建问题 (#4196)

This commit is contained in:
hsm-lv 2022-04-29 19:34:38 +08:00 committed by GitHub
parent 6d83e387e7
commit ba9cf4a7f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 83 additions and 114 deletions

View File

@ -3,27 +3,11 @@ 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 {
@ -33,7 +17,7 @@ export enum LoopStatus {
}
// 监听器动作定义
export interface IListenerAction {
export interface ListenerAction {
actionType: string; // 动作类型 逻辑动作|自定义(脚本支撑)|reload|url|ajax|dialog|drawer 其他扩充的组件动作
description?: string; // 事件描述actionType: broadcast
componentId?: string; // 组件ID用于直接执行指定组件的动作
@ -44,26 +28,7 @@ export interface IListenerAction {
expression?: string; // 执行条件
}
// 监听器动作联合类型
export type ListenerAction =
| IToastAction
| IBroadcastAction
| IAjaxAction
| ICmptAction
| ICopyAction
| ICustomAction
| IAlertAction
| IConfirmAction
| IDialogAction
| ICloseDialogAction
| IDrawerAction
| ICloseDrawerAction
| IEmailAction
| ILinkAction
| LogicAction
| IPageGoAction;
export interface ILogicAction extends IListenerAction {
export interface ILogicAction extends ListenerAction {
children?: ListenerAction[]; // 子动作
}

View File

@ -1,17 +1,17 @@
import omit from 'lodash/omit';
import { Api } from '../types';
import { normalizeApiResponseData } from '../utils/api';
import { ServerError } from '../utils/errors';
import { createObject, isEmpty } from '../utils/helper';
import { RendererEvent } from '../utils/renderer-event';
import {Api} from '../types';
import {normalizeApiResponseData} from '../utils/api';
import {ServerError} from '../utils/errors';
import {createObject, isEmpty} from '../utils/helper';
import {RendererEvent} from '../utils/renderer-event';
import {
RendererAction,
IListenerAction,
ListenerAction,
ListenerContext,
registerAction
} from './Action';
export interface IAjaxAction extends IListenerAction {
export interface IAjaxAction extends ListenerAction {
action: 'ajax';
args: {
api: Api;
@ -19,7 +19,7 @@ export interface IAjaxAction extends IListenerAction {
success: string;
failed: string;
};
options?: Record<string, any>
options?: Record<string, any>;
[propName: string]: any;
};
}
@ -57,8 +57,8 @@ export class AjaxAction implements RendererAction {
event.data,
action.outputVar
? {
[`${action.outputVar}`]: responseData
}
[`${action.outputVar}`]: responseData
}
: responseData
)
);
@ -77,9 +77,9 @@ export class AjaxAction implements RendererAction {
msg,
result.msgTimeout !== undefined
? {
closeButton: true,
timeout: result.msgTimeout
}
closeButton: true,
timeout: result.msgTimeout
}
: undefined
);
}
@ -93,9 +93,9 @@ export class AjaxAction implements RendererAction {
e.message,
result.msgTimeout !== undefined
? {
closeButton: true,
timeout: result.msgTimeout
}
closeButton: true,
timeout: result.msgTimeout
}
: undefined
);
} else {

View File

@ -1,14 +1,14 @@
import { RendererProps } from '../factory';
import { createObject } from '../utils/helper';
import { RendererEvent, dispatchEvent } from '../utils/renderer-event';
import {RendererProps} from '../factory';
import {createObject} from '../utils/helper';
import {RendererEvent, dispatchEvent} from '../utils/renderer-event';
import {
RendererAction,
IListenerAction,
ListenerAction,
ListenerContext,
registerAction
} from './Action';
export interface IBroadcastAction extends IListenerAction {
export interface IBroadcastAction extends ListenerAction {
actionType: 'broadcast';
eventName: string; // 事件名称actionType: broadcast
}

View File

@ -1,16 +1,22 @@
import { RendererEvent } from '../utils/renderer-event';
import {RendererEvent} from '../utils/renderer-event';
import {
RendererAction,
IListenerAction,
ListenerAction,
ListenerContext,
registerAction
} from './Action';
export interface ICmptAction extends IListenerAction {
actionType: 'setValue' | 'show' | 'hidden' | 'enabled' | 'disabled' | 'reload';
export interface ICmptAction extends ListenerAction {
actionType:
| 'setValue'
| 'show'
| 'hidden'
| 'enabled'
| 'disabled'
| 'reload';
args: {
value?: string | { [key: string]: string };
}
value?: string | {[key: string]: string};
};
}
/**

View File

@ -1,12 +1,12 @@
import { RendererEvent } from '../utils/renderer-event';
import {RendererEvent} from '../utils/renderer-event';
import {
RendererAction,
IListenerAction,
ListenerAction,
ListenerContext,
registerAction
} from './Action';
export interface ICopyAction extends IListenerAction {
export interface ICopyAction extends ListenerAction {
actionType: 'copy';
args: {
content: string;

View File

@ -1,21 +1,22 @@
import { Action } from '../types';
import { RendererEvent } from '../utils/renderer-event';
import {Action} from '../types';
import {RendererEvent} from '../utils/renderer-event';
import {
RendererAction,
IListenerAction,
ListenerAction,
ListenerContext,
registerAction,
ListenerAction
registerAction
} from './Action';
export interface ICustomAction extends IListenerAction {
export interface ICustomAction extends ListenerAction {
actionType: 'custom';
script: string | ((
renderer: any,
doAction: (action: Action, data: Record<string, any>) => void,
event: RendererEvent<any>,
action: ListenerAction,
) => void); // 自定义JSactionType: custom
script:
| string
| ((
renderer: any,
doAction: (action: Action, data: Record<string, any>) => void,
event: RendererEvent<any>,
action: ListenerAction
) => void); // 自定义JSactionType: custom
}
/**
@ -49,7 +50,7 @@ export class CustomAction implements RendererAction {
null,
renderer,
renderer.props.onAction?.bind(renderer, event.context.nativeEvent) ||
renderer.doAction?.bind(renderer),
renderer.doAction?.bind(renderer),
event,
action
);

View File

@ -1,14 +1,13 @@
import { SchemaNode } from '../types';
import { RendererEvent } from '../utils/renderer-event';
import {SchemaNode} from '../types';
import {RendererEvent} from '../utils/renderer-event';
import {
RendererAction,
ListenerAction,
IListenerAction,
ListenerContext,
registerAction
} from './Action';
export interface IAlertAction extends IListenerAction {
export interface IAlertAction extends ListenerAction {
actionType: 'alert';
args: {
msg: string;
@ -16,7 +15,7 @@ export interface IAlertAction extends IListenerAction {
};
}
export interface IConfirmAction extends IListenerAction {
export interface IConfirmAction extends ListenerAction {
actionType: 'confirm';
args: {
title: string;
@ -25,7 +24,7 @@ export interface IConfirmAction extends IListenerAction {
};
}
export interface IDialogAction extends IListenerAction {
export interface IDialogAction extends ListenerAction {
actionType: 'dialog';
dialog: SchemaNode;
}
@ -47,7 +46,7 @@ export class DialogAction implements RendererAction {
}
}
export interface ICloseDialogAction extends IListenerAction {
export interface ICloseDialogAction extends ListenerAction {
actionType: 'closeDialog';
}

View File

@ -1,14 +1,13 @@
import { SchemaNode } from '../types';
import { RendererEvent } from '../utils/renderer-event';
import {SchemaNode} from '../types';
import {RendererEvent} from '../utils/renderer-event';
import {
RendererAction,
IListenerAction,
ListenerAction,
ListenerContext,
registerAction
} from './Action';
export interface IDrawerAction extends IListenerAction {
export interface IDrawerAction extends ListenerAction {
actionType: 'drawer';
drawer: SchemaNode;
}
@ -30,11 +29,10 @@ export class DrawerAction implements RendererAction {
}
}
export interface ICloseDrawerAction extends IListenerAction {
export interface ICloseDrawerAction extends ListenerAction {
actionType: 'closeDrawer';
}
/**
*
*

View File

@ -1,14 +1,14 @@
import { RendererEvent } from '../utils/renderer-event';
import {RendererEvent} from '../utils/renderer-event';
import pick from 'lodash/pick';
import qs from 'qs';
import {
RendererAction,
ListenerContext,
registerAction,
IListenerAction
ListenerAction
} from './Action';
export interface IEmailAction extends IListenerAction {
export interface IEmailAction extends ListenerAction {
actionType: 'email';
args: {
to: string;

View File

@ -1,14 +1,14 @@
import { buildApi } from '../utils/api';
import { RendererEvent } from '../utils/renderer-event';
import {buildApi} from '../utils/api';
import {RendererEvent} from '../utils/renderer-event';
import omit from 'lodash/omit';
import {
RendererAction,
ListenerContext,
registerAction,
IListenerAction
ListenerAction
} from './Action';
export interface ILinkAction extends IListenerAction {
export interface ILinkAction extends ListenerAction {
actionType: 'link' | 'url' | 'jump';
args: {
link?: string;

View File

@ -1,12 +1,12 @@
import { RendererEvent } from '../utils/renderer-event';
import {RendererEvent} from '../utils/renderer-event';
import {
RendererAction,
IListenerAction,
ListenerAction,
ListenerContext,
registerAction
} from './Action';
export interface IPageGoAction extends IListenerAction {
export interface IPageGoAction extends ListenerAction {
actionType: 'goBack' | 'refresh' | 'goPage';
args: {
delta?: number;

View File

@ -1,28 +1,28 @@
import { RendererEvent } from '../utils/renderer-event';
import {RendererEvent} from '../utils/renderer-event';
import {
RendererAction,
ListenerContext,
registerAction,
IListenerAction
ListenerAction
} from './Action';
export interface IToastAction extends IListenerAction {
export interface IToastAction extends ListenerAction {
actionType: 'toast';
args: {
msg: string;
msgType?: string;
position?:
| 'top-right'
| 'top-center'
| 'top-left'
| 'bottom-center'
| 'bottom-left'
| 'bottom-right'
| 'center';
| 'top-right'
| 'top-center'
| 'top-left'
| 'bottom-center'
| 'bottom-left'
| 'bottom-right'
| 'center';
closeButton?: boolean;
showIcon?: boolean;
timeout?: number;
}
};
}
/**