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;