From a3445771f0752ac09a853025e7862de8902c71b9 Mon Sep 17 00:00:00 2001 From: ZLY Date: Tue, 28 Oct 2025 15:41:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(appEvent):=20=E6=96=B0=E5=A2=9E=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E7=BC=96=E6=8E=92=E6=95=B0=E6=8D=AE=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/appEvent.ts | 10 ++++++++++ src/hooks/useFlowCallbacks.ts | 37 ++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/api/appEvent.ts b/src/api/appEvent.ts index e22fb24..bd02d95 100644 --- a/src/api/appEvent.ts +++ b/src/api/appEvent.ts @@ -17,4 +17,14 @@ export function getAppEventList(id: any) { // 更新事件 export function updateAppEvent(id: any, data: any) { return axios.post(`${urlPrefix}/appEvent/${id}/update`, data); +} + +// 更新应用编排数据 +export function updateAppFlowData(data: any) { + return axios.post(`${urlPrefix}/appEvent/update`, data); +} + +// 修改应用编排中的事件通道 +export function updateAppEventChannel(data: any) { + return axios.post(`${urlPrefix}/appEvent/updateTopic`, data); } \ No newline at end of file diff --git a/src/hooks/useFlowCallbacks.ts b/src/hooks/useFlowCallbacks.ts index 3a4e292..94a3379 100644 --- a/src/hooks/useFlowCallbacks.ts +++ b/src/hooks/useFlowCallbacks.ts @@ -32,7 +32,8 @@ import { appFLowHandle } from '@/pages/flowEditor/utils/appFlowhandle'; import { Dispatch } from 'redux'; import { runMainFlow } from '@/api/apps'; import store from '@/store'; -import { updateAppEvent } from '@/api/appEvent'; +import { updateAppEvent, updateAppEventChannel, updateAppFlowData } from '@/api/appEvent'; +import { sleep } from '@/utils/common'; export const useFlowCallbacks = ( nodes: Node[], @@ -1182,6 +1183,40 @@ export const useFlowCallbacks = ( nodes, edges }; + const appFlowParams = { + appEventList: {} + }; + + nodes.forEach(node => { + appFlowParams.appEventList[node.id] = { + x: node.position.x, + y: node.position.y + }; + }); + + const eventMap = new Map(); + edges.forEach((edge: any) => { + const eventId = edge.data.displayData.eventId; + const dto = { + eventId: eventId, + topicDTO: { + topic: edge.data.displayData.topic, + eventName: edge.data.displayData.name + } + }; + eventMap.set(eventId, dto); + }); + const appEventParams = Array.from(eventMap.values()); + + updateAppFlowData(appFlowParams); + if (appEventParams.length > 0) { + for (const item of appEventParams) { + console.log('item:', item); + await sleep(500); + updateAppEventChannel(item); + } + } + } }, [nodes, edges, initialData?.appId]); // 运行处理函数