Files
dooring/packages/dooringx-example/src/plugin/functionMap/index.ts

70 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-07-10 19:35:06 +08:00
/*
* @Author: yehuozhili
* @Date: 2021-07-07 14:22:51
* @LastEditors: yehuozhili
2022-04-24 00:38:03 +08:00
* @LastEditTime: 2022-04-24 00:11:35
2021-07-10 19:35:06 +08:00
* @FilePath: \dooringx\packages\dooringx-example\src\plugin\functionMap\index.ts
*/
import { FunctionCenterType } from 'dooringx-lib/dist/core/functionCenter';
2021-08-05 15:13:57 +08:00
export const functionMap: FunctionCenterType = {
2022-04-24 00:38:03 +08:00
sleep: {
fn: (ctx, next, _config, args) => {
const arr = args['_sk'];
let num = parseInt(arr[0]);
if (isNaN(num)) {
next();
} else {
setTimeout(() => {
next();
}, arr[0]);
}
},
config: [
{
name: '输入数值单位ms',
data: ['input'],
options: {
receive: '_sk',
multi: false,
},
},
],
name: '等待',
componentId: '_inner',
},
2021-08-05 15:13:57 +08:00
: {
fn: (ctx, next, _config, args) => {
const arr = args['_sk'];
const key = args['_r'];
const param: Record<string, any> = {};
arr.forEach((v: string) => {
param[v] = ctx[v];
});
ctx[key] = param;
console.log(ctx);
next();
},
config: [
{
name: '输入要获取的上下文',
data: ['ctx'],
options: {
receive: '_sk',
multi: true,
},
},
{
name: '输入要生成的上下文',
data: ['ctx'],
options: {
receive: '_r',
multi: false,
},
},
],
2021-11-05 10:36:06 +08:00
name: '上下文转对象',
2022-04-24 00:38:03 +08:00
componentId: '_inner',
2021-08-05 15:13:57 +08:00
},
};