import React, { useState, useEffect } from 'react'; import { Node } from '@xyflow/react'; import { Modal, Input, Form, Select } from '@arco-design/web-react'; interface NodeData { type?: string; title?: string; parameters?: any; component?: any; [key: string]: any; } interface NodeEditModalProps { node: Node; isOpen: boolean; onSave: (data: any) => void; onClose: () => void; } const NodeEditModal: React.FC = ({ node, isOpen, onSave, onClose }) => { const [nodeData, setNodeData] = useState({}); const [visible, setVisible] = useState(false); useEffect(() => { if (node) { setNodeData(node.data || {}); } }, [node]); useEffect(() => { setVisible(isOpen); }, [isOpen]); if (!isOpen || !node) return null; const handleSave = () => { setVisible(false); onSave(nodeData); }; const handleClose = () => { setVisible(false); onClose(); }; // 更新节点数据的通用函数 const updateNodeData = (key: string, value: any) => { setNodeData(prev => ({ ...prev, [key]: value })); }; // 根据节点类型渲染不同的内容 const renderContent = () => { const nodeType = node?.type || 'basic'; switch (nodeType) { case 'start': case 'end': case 'basic': default: return (
updateNodeData('title', value)} /> updateNodeData('description', value)} />