diff --git a/ui/src/components/workflow/node/_SharedNode.tsx b/ui/src/components/workflow/node/_SharedNode.tsx index 07cd4cdd..cd067e36 100644 --- a/ui/src/components/workflow/node/_SharedNode.tsx +++ b/ui/src/components/workflow/node/_SharedNode.tsx @@ -2,7 +2,6 @@ import { memo, useMemo, useRef } from "react"; import { useTranslation } from "react-i18next"; import { CloseCircleOutlined as CloseCircleOutlinedIcon, - CopyOutlined as CopyOutlinedIcon, EllipsisOutlined as EllipsisOutlinedIcon, FormOutlined as FormOutlinedIcon, MoreOutlined as MoreOutlinedIcon, @@ -12,7 +11,7 @@ import { Button, Card, Drawer, Dropdown, Input, type InputRef, type MenuProps, M import { produce } from "immer"; import { isEqual } from "radash"; -import { type WorkflowNode, WorkflowNodeType, newNode } from "@/domain/workflow"; +import { type WorkflowNode, WorkflowNodeType } from "@/domain/workflow"; import { useZustandShallowSelector } from "@/hooks"; import { useWorkflowStore } from "@/stores/workflow"; @@ -83,7 +82,7 @@ const isNodeReadOnly = (node: WorkflowNode) => { const SharedNodeMenu = ({ menus, trigger, node, disabled, branchId, branchIndex, afterUpdate, afterDelete }: SharedNodeMenuProps) => { const { t } = useTranslation(); - const { updateNode, removeNode, removeBranch, addNode } = useWorkflowStore(useZustandShallowSelector(["updateNode", "removeNode", "removeBranch", "addNode"])); + const { updateNode, removeNode, removeBranch } = useWorkflowStore(useZustandShallowSelector(["updateNode", "removeNode", "removeBranch"])); const [modalApi, ModelContextHolder] = Modal.useModal(); @@ -106,49 +105,6 @@ const SharedNodeMenu = ({ menus, trigger, node, disabled, branchId, branchIndex, afterUpdate?.(); }; - const handleCopyNode = async () => { - try { - // Clone the node by creating a new node of the same type - const clonedNode = newNode(node.type); - // Copy over configurations - clonedNode.name = `${node.name} (副本)`; - - // Copy all configurable properties - if (node.config) { - clonedNode.config = JSON.parse(JSON.stringify(node.config)); - } - - if (node.inputs) { - clonedNode.inputs = JSON.parse(JSON.stringify(node.inputs)); - } - - if (node.outputs) { - clonedNode.outputs = JSON.parse(JSON.stringify(node.outputs)); - } - - if (node.validated !== undefined) { - clonedNode.validated = node.validated; - } - - // For branch nodes, we need to deep copy the branches structure - if (node.branches && node.type === WorkflowNodeType.Branch) { - // For branch nodes, we'll keep the structure but with new IDs - // This ensures we don't run into ID conflicts - clonedNode.branches = newNode(WorkflowNodeType.Branch).branches; - } else if (node.branches && node.type === WorkflowNodeType.ExecuteResultBranch) { - // For execute result branches, we'll keep the structure but with new IDs - clonedNode.branches = newNode(WorkflowNodeType.ExecuteResultBranch).branches; - } - - // Add the cloned node after the current node - await addNode(clonedNode, node.id); - - afterUpdate?.(); - } catch (err) { - console.error("Failed to copy node:", err); - } - }; - const handleDeleteClick = async () => { if (isNodeBranchLike(node)) { await removeBranch(branchId!, branchIndex!); @@ -394,4 +350,4 @@ export default { Menu: memo(SharedNodeMenu), Block: memo(SharedNodeBlock), ConfigDrawer: memo(SharedNodeConfigDrawer), -}; +}; \ No newline at end of file