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,29 +79,16 @@ const BasicEventFlow = () => {
|
||||
time: new Date().toLocaleString(),
|
||||
},
|
||||
meta: {
|
||||
actionParams: [
|
||||
{
|
||||
flow: 'demo-button-click-flow',
|
||||
params: {
|
||||
steps: {
|
||||
stepParams: {
|
||||
step1: {
|
||||
title: '第一步:简单对话框',
|
||||
width: 600,
|
||||
},
|
||||
step2: {
|
||||
title: '第二步:通知',
|
||||
description: '这是事件流的第二步,显示通知消息',
|
||||
duration: 3,
|
||||
},
|
||||
step3: {
|
||||
title: '第三步:表单对话框',
|
||||
width: 500,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
eventBus.dispatchEvent('button:click', ctx);
|
||||
|
@ -68,10 +68,7 @@ const ConditionalEventFlow = () => {
|
||||
option: selectedOption,
|
||||
},
|
||||
meta: {
|
||||
actionParams: [
|
||||
{
|
||||
flow: 'conditional-flow-demo',
|
||||
params: {
|
||||
stepParams: {
|
||||
step1: {
|
||||
title: '第一步:简单对话框',
|
||||
width: 600,
|
||||
@ -83,8 +80,6 @@ const ConditionalEventFlow = () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
// 触发原始事件名称
|
||||
|
@ -77,10 +77,7 @@ const ConditionalFlowTrigger = () => {
|
||||
time: new Date().toLocaleString(),
|
||||
},
|
||||
meta: {
|
||||
actionParams: [
|
||||
{
|
||||
flow: 'conditional-trigger-flow',
|
||||
params: {
|
||||
stepParams: {
|
||||
step1: {
|
||||
title: '阈值警告',
|
||||
width: 500,
|
||||
@ -91,8 +88,6 @@ const ConditionalFlowTrigger = () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
// 触发原始事件名称
|
||||
|
@ -167,15 +167,10 @@ const ConfigurableActionDemo = () => {
|
||||
const ctx = {
|
||||
payload: {},
|
||||
meta: {
|
||||
actionParams: [
|
||||
{
|
||||
flow: 'message-flow',
|
||||
params: {
|
||||
stepParams: {
|
||||
'message-step': currentParams,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
eventBus.dispatchEvent('button:click', ctx);
|
||||
};
|
||||
|
@ -99,10 +99,7 @@ const DataPassingEventFlow = () => {
|
||||
time: new Date().toLocaleString(),
|
||||
},
|
||||
meta: {
|
||||
actionParams: [
|
||||
{
|
||||
flow: 'data-passing-flow',
|
||||
params: {
|
||||
stepParams: {
|
||||
step1: {
|
||||
prefix: '已处理: ',
|
||||
},
|
||||
@ -112,8 +109,6 @@ const DataPassingEventFlow = () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
// 触发原始事件名称
|
||||
|
@ -145,15 +145,10 @@ const MultiButtonEventFlow = () => {
|
||||
time: new Date().toLocaleString(),
|
||||
},
|
||||
meta: {
|
||||
actionParams: [
|
||||
{
|
||||
flow: `button${buttonNum}-flow`,
|
||||
params: {
|
||||
stepParams: {
|
||||
step1: stepParams,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
// 触发原始事件名称
|
||||
|
@ -210,7 +210,7 @@ export class EventFlow {
|
||||
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);
|
||||
|
||||
if (!this.hasSteps()) {
|
||||
@ -248,7 +248,7 @@ export class EventFlow {
|
||||
const action = this.eventFlowManager.getAction(step.action);
|
||||
if (action) {
|
||||
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) {
|
||||
await this.executeHandler(action.handler, stepParams, context);
|
||||
} else {
|
||||
|
@ -26,14 +26,8 @@ export interface EventContext<T = any> {
|
||||
userId?: string;
|
||||
event?: string | string[]; // 事件名称, 一个事件是可以触发多个eventflow的,与filterflow不同
|
||||
[key: string]: any;
|
||||
eventParams?: {
|
||||
flow?: string;
|
||||
params?: Record<string, Record<string, any>>;
|
||||
}[];
|
||||
actionParams?: {
|
||||
flow?: string;
|
||||
params?: Record<string, Record<string, any>>;
|
||||
}[];
|
||||
eventParams?: Record<string, Record<string, any>>;
|
||||
stepParams?: Record<string, Record<string, any>>;
|
||||
};
|
||||
payload?: T;
|
||||
results?: Record<string, any>;
|
||||
|
Loading…
x
Reference in New Issue
Block a user