diff --git a/src/pages/flowEditor/components/nodeEditModal.tsx b/src/pages/flowEditor/components/nodeEditModal.tsx index 71b0e89..9fdbe34 100644 --- a/src/pages/flowEditor/components/nodeEditModal.tsx +++ b/src/pages/flowEditor/components/nodeEditModal.tsx @@ -1,9 +1,18 @@ import React, { useState, useEffect } from 'react'; import { Node } from '@xyflow/react'; -import { Modal, Button } from '@arco-design/web-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 | any; + node: Node; isOpen: boolean; onSave: (data: any) => void; onClose: () => void; @@ -15,12 +24,12 @@ const NodeEditModal: React.FC = ({ onSave, onClose }) => { - const [title, setTitle] = useState(''); - const [visible, setVisible] = React.useState(false); + const [nodeData, setNodeData] = useState({}); + const [visible, setVisible] = useState(false); useEffect(() => { if (node) { - setTitle(node.data?.title || ''); + setNodeData(node.data || {}); } }, [node]); @@ -32,7 +41,7 @@ const NodeEditModal: React.FC = ({ const handleSave = () => { setVisible(false); - onSave({ title }); + onSave(nodeData); }; const handleClose = () => { @@ -40,66 +49,59 @@ const NodeEditModal: React.FC = ({ onClose(); }; + // 更新节点数据的通用函数 + const updateNodeData = (key: string, value: any) => { + setNodeData(prev => ({ + ...prev, + [key]: value + })); + }; + // 根据节点类型渲染不同的内容 const renderContent = () => { const nodeType = node?.type || 'basic'; switch (nodeType) { case 'start': - return ( -
-

开始节点设置

-
- - setTitle(e.target.value)} - style={{ width: '100%', padding: '8px', margin: '10px 0' }} - /> -
-
- ); case 'end': - return ( -
-

结束节点设置

-
- - setTitle(e.target.value)} - style={{ width: '100%', padding: '8px', margin: '10px 0' }} - /> -
-
- ); case 'basic': default: return ( -
-

基础节点设置

-
- - setTitle(e.target.value)} - style={{ width: '100%', padding: '8px', margin: '10px 0' }} +
+ + updateNodeData('title', value)} + /> + + + updateNodeData('description', value)} + /> + + +