From c277b3dff113d1a651af03ffa4b2abecc03eff38 Mon Sep 17 00:00:00 2001 From: deepkolos Date: Sat, 7 Oct 2023 20:30:46 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix:=20menu=20delete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/view/popups/EditorMenu.tsx | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 60a0606..392f59c 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ - 函数节点内容不方便编辑 先提供个方便编辑的地方 - 参数更新复用老参数配置 - 链接稍微困难, 需要增大识别区域 ✅ - - 右键未触发节点选择 导致删除可能误删 + - 右键未触发节点选择 导致删除可能误删, 先增加提示+顺序调整规避 ✅ - 右键菜单二级菜单无法显示 ✅ # 赞助 diff --git a/src/view/popups/EditorMenu.tsx b/src/view/popups/EditorMenu.tsx index 8d73642..85ecbeb 100644 --- a/src/view/popups/EditorMenu.tsx +++ b/src/view/popups/EditorMenu.tsx @@ -183,9 +183,11 @@ const EditorContextMenu: FC = ({ editor, connection, node, popupAdd, }, ]; + const hideDeleteNode = (!node || node.meta.undeleteable) && selectedCloneableNodes.length === 0; + const hideDeleteConnection = !connection || (connection.data as any).fixed; const deleteNode = (node || selectedCloneableNodes.length) && [ { - name: '删除', + name: '删除' + (hideDeleteConnection ? '' : '节点'), onclick: () => { try { if (node && !editor.selected.contains(node)) editor.removeNode(node); @@ -196,13 +198,13 @@ const EditorContextMenu: FC = ({ editor, connection, node, popupAdd, view.hide(); } }, - disabled: (!node || node.meta.undeleteable) && selectedCloneableNodes.length === 0, + disabled: hideDeleteNode, }, ]; const deleteConnection = connection && [ { - name: '删除', + name: '删除' + (hideDeleteNode ? '' : '连线'), onclick: () => { try { editor.removeConnection(connection!); @@ -212,7 +214,7 @@ const EditorContextMenu: FC = ({ editor, connection, node, popupAdd, view.hide(); } }, - disabled: !connection || (connection.data as any).fixed, + disabled: hideDeleteConnection, }, ]; @@ -249,8 +251,8 @@ const EditorContextMenu: FC = ({ editor, connection, node, popupAdd, copyShaderLink, addNode, copyPasteCut, - deleteNode, deleteConnection, + deleteNode, // !connection && [{ name: '克隆', onclick: () => {}, disabled: true }], selectUnusedNode, ].filter(i => !!i) as MenuListProps['items']