import { useEffect } from 'react'; import clsx from 'clsx'; import { Dropdown } from 'antd'; import { SmallDashOutlined } from '@ant-design/icons'; import type { ReactShapeConfig } from '@antv/x6-react-shape'; import { graphNodeLibrary } from '../../constant'; interface NodeData { isSelected?: boolean; type?: string; label?: string; icon?: string; parentId?: string; isGroup?: boolean; } const IterationNode: ReactShapeConfig['component'] = ({ node, graph }) => { const data = node.getData() as NodeData; useEffect(() => { initNodes() }, []) const initNodes = () => { // 添加默认子节点 const parentBBox = node.getBBox(); const centerX = parentBBox.x + 24; // 默认节点宽度的一半 const centerY = parentBBox.y + 50; // 默认节点高度的一半 const childNode1 = graph.addNode({ ...graphNodeLibrary.groupStart, x: centerX, y: centerY, data: { type: 'default', label: '开始', // icon: '📌', parentId: node.id, isDefault: true // 标记为默认节点,不可删除 }, }); const childNode2 = graph.addNode({ ...graphNodeLibrary.addStart, x: centerX + 150, y: centerY, data: { type: 'default', label: '添加节点', icon: '+', parentId: node.id, }, }); node.addChild(childNode1) node.addChild(childNode2) } return (
{/* 标题区域 */}
🔁
迭代
{/* 画布内容区域 */}
); }; export default IterationNode;