chore: api update

This commit is contained in:
gchust 2025-04-20 10:17:14 +08:00
parent a57db34dd1
commit 2ac824c85a
8 changed files with 45 additions and 89 deletions

View File

@ -79,29 +79,16 @@ const BasicEventFlow = () => {
time: new Date().toLocaleString(), time: new Date().toLocaleString(),
}, },
meta: { meta: {
actionParams: [ stepParams: {
{
flow: 'demo-button-click-flow',
params: {
steps: {
step1: { step1: {
title: '第一步:简单对话框', title: '第一步:简单对话框',
width: 600, width: 600,
}, },
step2: { step2: {
title: '第二步:通知', title: '第二步:通知',
description: '这是事件流的第二步,显示通知消息',
duration: 3,
},
step3: {
title: '第三步:表单对话框',
width: 500,
}, },
}, },
}, },
},
],
},
}; };
eventBus.dispatchEvent('button:click', ctx); eventBus.dispatchEvent('button:click', ctx);

View File

@ -68,10 +68,7 @@ const ConditionalEventFlow = () => {
option: selectedOption, option: selectedOption,
}, },
meta: { meta: {
actionParams: [ stepParams: {
{
flow: 'conditional-flow-demo',
params: {
step1: { step1: {
title: '第一步:简单对话框', title: '第一步:简单对话框',
width: 600, width: 600,
@ -83,8 +80,6 @@ const ConditionalEventFlow = () => {
}, },
}, },
}, },
],
},
}; };
// 触发原始事件名称 // 触发原始事件名称

View File

@ -77,10 +77,7 @@ const ConditionalFlowTrigger = () => {
time: new Date().toLocaleString(), time: new Date().toLocaleString(),
}, },
meta: { meta: {
actionParams: [ stepParams: {
{
flow: 'conditional-trigger-flow',
params: {
step1: { step1: {
title: '阈值警告', title: '阈值警告',
width: 500, width: 500,
@ -91,8 +88,6 @@ const ConditionalFlowTrigger = () => {
}, },
}, },
}, },
],
},
}; };
// 触发原始事件名称 // 触发原始事件名称

View File

@ -167,15 +167,10 @@ const ConfigurableActionDemo = () => {
const ctx = { const ctx = {
payload: {}, payload: {},
meta: { meta: {
actionParams: [ stepParams: {
{
flow: 'message-flow',
params: {
'message-step': currentParams, 'message-step': currentParams,
}, },
}, },
],
},
}; };
eventBus.dispatchEvent('button:click', ctx); eventBus.dispatchEvent('button:click', ctx);
}; };

View File

@ -99,10 +99,7 @@ const DataPassingEventFlow = () => {
time: new Date().toLocaleString(), time: new Date().toLocaleString(),
}, },
meta: { meta: {
actionParams: [ stepParams: {
{
flow: 'data-passing-flow',
params: {
step1: { step1: {
prefix: '已处理: ', prefix: '已处理: ',
}, },
@ -112,8 +109,6 @@ const DataPassingEventFlow = () => {
}, },
}, },
}, },
],
},
}; };
// 触发原始事件名称 // 触发原始事件名称

View File

@ -145,15 +145,10 @@ const MultiButtonEventFlow = () => {
time: new Date().toLocaleString(), time: new Date().toLocaleString(),
}, },
meta: { meta: {
actionParams: [ stepParams: {
{
flow: `button${buttonNum}-flow`,
params: {
step1: stepParams, step1: stepParams,
}, },
}, },
],
},
}; };
// 触发原始事件名称 // 触发原始事件名称

View File

@ -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 {

View File

@ -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>;