From c9a61f762a49ab77030947955603232ca3529880 Mon Sep 17 00:00:00 2001 From: ZLY Date: Thu, 25 Dec 2025 11:18:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(flowEditor):=20=E6=B7=BB=E5=8A=A0=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E8=8A=82=E7=82=B9=E5=8D=95=E6=AD=A5=E6=89=A7=E8=A1=8C?= =?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/apps.ts | 26 +++++++++++- .../flowEditor/components/nodeContextMenu.tsx | 42 ++++++++++++++++++- 2 files changed, 65 insertions(+), 3 deletions(-) diff --git a/src/api/apps.ts b/src/api/apps.ts index b437b82..b72d6f7 100644 --- a/src/api/apps.ts +++ b/src/api/apps.ts @@ -1,5 +1,14 @@ import axios from 'axios'; -import { apiResData, queryParams, applicationModel, publishApi, paramsT } from '@/api/interface/index'; +import { + apiResData, + queryParams, + applicationModel, + publishApi, + paramsT, + StepRunEventParams, + ExecuteCurrentEventParams, + ReconnectRunParams +} from '@/api/interface/index'; // 公共路径 const urlPrefix = '/api/v1/bpms-workbench'; @@ -109,3 +118,18 @@ export function refreshToken(data: publishApi) { export function getProjectEnv(id) { return axios.get(`${urlPrefix}/apps/env/${id}`); } + +// 事件运行时-单步执行事件 +export function stepRunEvent(params: StepRunEventParams) { + return axios.post(`${runPrefix}/apps/run/event`, params); +} + +// 事件运行时-从当前节点执行 +export function executeCurrentEvent(params: ExecuteCurrentEventParams) { + return axios.post(`${runPrefix}/apps/breakpoint`, params); +} + +// 流程运行时-重连运行 +export function reconnectRun(params: ReconnectRunParams) { + return axios.post(`${runPrefix}/apps/reconnect`, params); +} \ No newline at end of file diff --git a/src/pages/flowEditor/components/nodeContextMenu.tsx b/src/pages/flowEditor/components/nodeContextMenu.tsx index b0e90bd..26b1f37 100644 --- a/src/pages/flowEditor/components/nodeContextMenu.tsx +++ b/src/pages/flowEditor/components/nodeContextMenu.tsx @@ -1,7 +1,8 @@ -import React, { useEffect } from 'react'; +import React from 'react'; import { Menu, Message } from '@arco-design/web-react'; import { Node } from '@xyflow/react'; import { isJSON } from '@/utils/common'; +import { stepRunEvent } from '@/api/apps'; interface NodeContextMenuProps { node: Node; @@ -53,6 +54,34 @@ const NodeContextMenu: React.FC = ({ onCloseMenu(null); }; + // 单步执行事件 + const handleStepRun = async () => { + try { + // 从节点的 component.customDef 中获取事件ID + let eventId = ''; + const customDef = (node as any).data?.component?.customDef; + if (customDef) { + if (typeof customDef === 'string') { + const parsed = isJSON(customDef) ? JSON.parse(customDef) : {}; + eventId = parsed.eventId || ''; + } else { + eventId = customDef.eventId || ''; + } + } + + if (!eventId) { + Message.warning('该节点未配置事件,请先选择事件'); + onCloseMenu(null); + return; + } + + await stepRunEvent({ eventId }); + Message.success('单步执行已触发'); + } catch (error: any) { + Message.error(error?.message || '单步执行失败'); + } + onCloseMenu(null); + }; // 根据节点类型和其他条件动态生成菜单项 const renderMenuItems = () => { @@ -79,6 +108,15 @@ const NodeContextMenu: React.FC = ({ 删除节点 ); + + // 单步执行 - 仅对事件接收节点显示 + if (node.data.type === 'EVENTLISTENE') { + menuItems.push( + + 单步执行 + + ); + } } // 可以根据节点类型添加特定的操作 @@ -100,4 +138,4 @@ const NodeContextMenu: React.FC = ({ ); }; -export default NodeContextMenu; \ No newline at end of file +export default NodeContextMenu;