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

View File

@ -68,22 +68,17 @@ const ConditionalEventFlow = () => {
option: selectedOption,
},
meta: {
actionParams: [
{
flow: 'conditional-flow-demo',
params: {
step1: {
title: '第一步:简单对话框',
width: 600,
},
step2: {
title: '选项B的通知',
description: '您选择了选项B',
duration: 3,
},
},
stepParams: {
step1: {
title: '第一步:简单对话框',
width: 600,
},
],
step2: {
title: '选项B的通知',
description: '您选择了选项B',
duration: 3,
},
},
},
};

View File

@ -77,21 +77,16 @@ const ConditionalFlowTrigger = () => {
time: new Date().toLocaleString(),
},
meta: {
actionParams: [
{
flow: 'conditional-trigger-flow',
params: {
step1: {
title: '阈值警告',
width: 500,
},
step2: {
title: '阈值超限警告',
duration: 5,
},
},
stepParams: {
step1: {
title: '阈值警告',
width: 500,
},
],
step2: {
title: '阈值超限警告',
duration: 5,
},
},
},
};

View File

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

View File

@ -99,20 +99,15 @@ const DataPassingEventFlow = () => {
time: new Date().toLocaleString(),
},
meta: {
actionParams: [
{
flow: 'data-passing-flow',
params: {
step1: {
prefix: '已处理: ',
},
step2: {
title: '数据处理结果',
duration: 5,
},
},
stepParams: {
step1: {
prefix: '已处理: ',
},
],
step2: {
title: '数据处理结果',
duration: 5,
},
},
},
};

View File

@ -145,14 +145,9 @@ const MultiButtonEventFlow = () => {
time: new Date().toLocaleString(),
},
meta: {
actionParams: [
{
flow: `button${buttonNum}-flow`,
params: {
step1: stepParams,
},
},
],
stepParams: {
step1: stepParams,
},
},
};

View File

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

View File

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