|
|
|
@ -1,7 +1,8 @@
|
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
import React from 'react';
|
|
|
|
import { Menu, Message } from '@arco-design/web-react';
|
|
|
|
import { Menu, Message } from '@arco-design/web-react';
|
|
|
|
import { Node } from '@xyflow/react';
|
|
|
|
import { Node } from '@xyflow/react';
|
|
|
|
import { isJSON } from '@/utils/common';
|
|
|
|
import { isJSON } from '@/utils/common';
|
|
|
|
|
|
|
|
import { stepRunEvent } from '@/api/apps';
|
|
|
|
|
|
|
|
|
|
|
|
interface NodeContextMenuProps {
|
|
|
|
interface NodeContextMenuProps {
|
|
|
|
node: Node;
|
|
|
|
node: Node;
|
|
|
|
@ -53,6 +54,34 @@ const NodeContextMenu: React.FC<NodeContextMenuProps> = ({
|
|
|
|
onCloseMenu(null);
|
|
|
|
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 = () => {
|
|
|
|
const renderMenuItems = () => {
|
|
|
|
@ -79,6 +108,15 @@ const NodeContextMenu: React.FC<NodeContextMenuProps> = ({
|
|
|
|
删除节点
|
|
|
|
删除节点
|
|
|
|
</Menu.Item>
|
|
|
|
</Menu.Item>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 单步执行 - 仅对事件接收节点显示
|
|
|
|
|
|
|
|
if (node.data.type === 'EVENTLISTENE') {
|
|
|
|
|
|
|
|
menuItems.push(
|
|
|
|
|
|
|
|
<Menu.Item key="step-run" onClick={handleStepRun}>
|
|
|
|
|
|
|
|
单步执行
|
|
|
|
|
|
|
|
</Menu.Item>
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 可以根据节点类型添加特定的操作
|
|
|
|
// 可以根据节点类型添加特定的操作
|
|
|
|
@ -100,4 +138,4 @@ const NodeContextMenu: React.FC<NodeContextMenuProps> = ({
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default NodeContextMenu;
|
|
|
|
export default NodeContextMenu;
|
|
|
|
|