import { memo } from "react"; import { useTranslation } from "react-i18next"; import { Button } from "antd"; import { type WorkflowBranchNode, type WorkflowNode } from "@/domain/workflow"; import { useZustandShallowSelector } from "@/hooks"; import { useWorkflowStore } from "@/stores/workflow"; import AddNode from "./AddNode"; import NodeRender from "./NodeRender"; import { type BrandNodeProps } from "./types"; const BranchNode = memo(({ data }: BrandNodeProps) => { const { addBranch } = useWorkflowStore(useZustandShallowSelector(["addBranch"])); const { t } = useTranslation(); const renderNodes = (node: WorkflowBranchNode | WorkflowNode | undefined, branchNodeId?: string, branchIndex?: number) => { const elements: JSX.Element[] = []; let current = node; while (current) { elements.push(); current = current.next; } return elements; }; return ( <>
{data.branches.map((branch, index) => (
{index == 0 && ( <>
)} {index == data.branches.length - 1 && ( <>
)} {/* 条件 1 */}
{renderNodes(branch, data.id, index)}
))}
); }); export default BranchNode;