diff --git a/src/pages/flowEditor/components/nodeContextMenu.tsx b/src/pages/flowEditor/components/nodeContextMenu.tsx index b41ea2e..a739018 100644 --- a/src/pages/flowEditor/components/nodeContextMenu.tsx +++ b/src/pages/flowEditor/components/nodeContextMenu.tsx @@ -1,5 +1,5 @@ import React, { useEffect } from 'react'; -import { Menu, Dropdown } from '@arco-design/web-react'; +import { Menu } from '@arco-design/web-react'; import { Node } from '@xyflow/react'; interface NodeContextMenuProps { @@ -34,26 +34,53 @@ const NodeContextMenu: React.FC = ({ const handleEdit = () => { onEdit && onEdit(node); - onCloseOpenModal(false); + onCloseOpenModal(true); onCloseMenu(null); }; + + // 根据节点类型和其他条件动态生成菜单项 + const renderMenuItems = () => { + const menuItems = []; + // if (!useDefault) return; + + // 对于非开始和结束节点,添加基本操作 + if (!['start', 'end'].includes(node?.type)) { + if (!['AND', 'OR', 'JSON2STR', 'STR2JSON', 'IMAGE', 'RESULT', 'LOOP_START'].includes(node.data.type as string)) { + menuItems.push( + + 编辑节点 + + ); + } + + menuItems.push( + + 复制节点 + + ); + menuItems.push( + + 删除节点 + + ); + } + + // 可以根据节点类型添加特定的操作 + if (node?.type === 'special') { + menuItems.push( + + 特殊操作 + + ); + } + + return menuItems; + }; + return ( - - 编辑节点 - - - {(!['start', 'end'].includes(node?.type)) && ( - <> - - 复制节点 - - - 删除节点 - - - )} + {renderMenuItems()} ); };