mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +08:00
chore: api update
This commit is contained in:
parent
a57db34dd1
commit
2ac824c85a
@ -79,28 +79,15 @@ const BasicEventFlow = () => {
|
|||||||
time: new Date().toLocaleString(),
|
time: new Date().toLocaleString(),
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
actionParams: [
|
stepParams: {
|
||||||
{
|
step1: {
|
||||||
flow: 'demo-button-click-flow',
|
title: '第一步:简单对话框',
|
||||||
params: {
|
width: 600,
|
||||||
steps: {
|
|
||||||
step1: {
|
|
||||||
title: '第一步:简单对话框',
|
|
||||||
width: 600,
|
|
||||||
},
|
|
||||||
step2: {
|
|
||||||
title: '第二步:通知',
|
|
||||||
description: '这是事件流的第二步,显示通知消息',
|
|
||||||
duration: 3,
|
|
||||||
},
|
|
||||||
step3: {
|
|
||||||
title: '第三步:表单对话框',
|
|
||||||
width: 500,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
step2: {
|
||||||
|
title: '第二步:通知',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,22 +68,17 @@ const ConditionalEventFlow = () => {
|
|||||||
option: selectedOption,
|
option: selectedOption,
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
actionParams: [
|
stepParams: {
|
||||||
{
|
step1: {
|
||||||
flow: 'conditional-flow-demo',
|
title: '第一步:简单对话框',
|
||||||
params: {
|
width: 600,
|
||||||
step1: {
|
|
||||||
title: '第一步:简单对话框',
|
|
||||||
width: 600,
|
|
||||||
},
|
|
||||||
step2: {
|
|
||||||
title: '选项B的通知',
|
|
||||||
description: '您选择了选项B',
|
|
||||||
duration: 3,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
step2: {
|
||||||
|
title: '选项B的通知',
|
||||||
|
description: '您选择了选项B',
|
||||||
|
duration: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,21 +77,16 @@ const ConditionalFlowTrigger = () => {
|
|||||||
time: new Date().toLocaleString(),
|
time: new Date().toLocaleString(),
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
actionParams: [
|
stepParams: {
|
||||||
{
|
step1: {
|
||||||
flow: 'conditional-trigger-flow',
|
title: '阈值警告',
|
||||||
params: {
|
width: 500,
|
||||||
step1: {
|
|
||||||
title: '阈值警告',
|
|
||||||
width: 500,
|
|
||||||
},
|
|
||||||
step2: {
|
|
||||||
title: '阈值超限警告',
|
|
||||||
duration: 5,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
step2: {
|
||||||
|
title: '阈值超限警告',
|
||||||
|
duration: 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -167,14 +167,9 @@ const ConfigurableActionDemo = () => {
|
|||||||
const ctx = {
|
const ctx = {
|
||||||
payload: {},
|
payload: {},
|
||||||
meta: {
|
meta: {
|
||||||
actionParams: [
|
stepParams: {
|
||||||
{
|
'message-step': currentParams,
|
||||||
flow: 'message-flow',
|
},
|
||||||
params: {
|
|
||||||
'message-step': currentParams,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
eventBus.dispatchEvent('button:click', ctx);
|
eventBus.dispatchEvent('button:click', ctx);
|
||||||
|
@ -99,20 +99,15 @@ const DataPassingEventFlow = () => {
|
|||||||
time: new Date().toLocaleString(),
|
time: new Date().toLocaleString(),
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
actionParams: [
|
stepParams: {
|
||||||
{
|
step1: {
|
||||||
flow: 'data-passing-flow',
|
prefix: '已处理: ',
|
||||||
params: {
|
|
||||||
step1: {
|
|
||||||
prefix: '已处理: ',
|
|
||||||
},
|
|
||||||
step2: {
|
|
||||||
title: '数据处理结果',
|
|
||||||
duration: 5,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
step2: {
|
||||||
|
title: '数据处理结果',
|
||||||
|
duration: 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -145,14 +145,9 @@ const MultiButtonEventFlow = () => {
|
|||||||
time: new Date().toLocaleString(),
|
time: new Date().toLocaleString(),
|
||||||
},
|
},
|
||||||
meta: {
|
meta: {
|
||||||
actionParams: [
|
stepParams: {
|
||||||
{
|
step1: stepParams,
|
||||||
flow: `button${buttonNum}-flow`,
|
},
|
||||||
params: {
|
|
||||||
step1: stepParams,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ export class EventFlow {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 触发器执行函数
|
// 触发器执行函数
|
||||||
const eventParams = context?.meta?.eventParams?.find((item) => item.flow === this.key)?.params;
|
const eventParams = context?.meta?.eventParams?.[this.key];
|
||||||
await this.executeHandler(event.handler, eventParams, context);
|
await this.executeHandler(event.handler, eventParams, context);
|
||||||
|
|
||||||
if (!this.hasSteps()) {
|
if (!this.hasSteps()) {
|
||||||
@ -248,7 +248,7 @@ export class EventFlow {
|
|||||||
const action = this.eventFlowManager.getAction(step.action);
|
const action = this.eventFlowManager.getAction(step.action);
|
||||||
if (action) {
|
if (action) {
|
||||||
if (this.checkCondition(step.condition, context)) {
|
if (this.checkCondition(step.condition, context)) {
|
||||||
const stepParams = context?.meta?.actionParams?.find((item) => item.flow === this.key)?.params?.[step.key];
|
const stepParams = context?.meta?.stepParams?.[step.key];
|
||||||
if (step.isAwait !== false) {
|
if (step.isAwait !== false) {
|
||||||
await this.executeHandler(action.handler, stepParams, context);
|
await this.executeHandler(action.handler, stepParams, context);
|
||||||
} else {
|
} else {
|
||||||
|
@ -26,14 +26,8 @@ export interface EventContext<T = any> {
|
|||||||
userId?: string;
|
userId?: string;
|
||||||
event?: string | string[]; // 事件名称, 一个事件是可以触发多个eventflow的,与filterflow不同
|
event?: string | string[]; // 事件名称, 一个事件是可以触发多个eventflow的,与filterflow不同
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
eventParams?: {
|
eventParams?: Record<string, Record<string, any>>;
|
||||||
flow?: string;
|
stepParams?: Record<string, Record<string, any>>;
|
||||||
params?: Record<string, Record<string, any>>;
|
|
||||||
}[];
|
|
||||||
actionParams?: {
|
|
||||||
flow?: string;
|
|
||||||
params?: Record<string, Record<string, any>>;
|
|
||||||
}[];
|
|
||||||
};
|
};
|
||||||
payload?: T;
|
payload?: T;
|
||||||
results?: Record<string, any>;
|
results?: Record<string, any>;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user