From 20c4184d45a4c07fae241684824ce95b5a26ba4d Mon Sep 17 00:00:00 2001 From: dengqichen Date: Mon, 20 Oct 2025 21:38:09 +0800 Subject: [PATCH] 1 --- .../Design/components/FlowCanvas.tsx | 4 +- .../Design/components/NodeConfigModal.tsx | 256 ++++++++++++ .../Design/components/PropertyPanel.tsx | 238 +++++++++++ .../Workflow2/Design/hooks/useWorkflowLoad.ts | 163 ++++++++ .../Workflow2/Design/hooks/useWorkflowSave.ts | 125 ++++++ frontend/src/pages/Workflow2/Design/index.tsx | 153 ++++++- frontend/src/pages/Workflow2/Design/types.ts | 11 +- .../src/pages/Workflow2/Instance/index.tsx | 383 +++++++++++++++++- .../src/pages/Workflow2/Instance/service.ts | 90 ++++ .../src/pages/Workflow2/Instance/types.ts | 88 ++++ .../src/pages/Workflow2/Monitor/index.tsx | 310 +++++++++++++- frontend/src/router/index.tsx | 60 ++- 12 files changed, 1799 insertions(+), 82 deletions(-) create mode 100644 frontend/src/pages/Workflow2/Design/components/NodeConfigModal.tsx create mode 100644 frontend/src/pages/Workflow2/Design/components/PropertyPanel.tsx create mode 100644 frontend/src/pages/Workflow2/Design/hooks/useWorkflowLoad.ts create mode 100644 frontend/src/pages/Workflow2/Design/hooks/useWorkflowSave.ts create mode 100644 frontend/src/pages/Workflow2/Instance/service.ts create mode 100644 frontend/src/pages/Workflow2/Instance/types.ts diff --git a/frontend/src/pages/Workflow2/Design/components/FlowCanvas.tsx b/frontend/src/pages/Workflow2/Design/components/FlowCanvas.tsx index 547f2244..83458257 100644 --- a/frontend/src/pages/Workflow2/Design/components/FlowCanvas.tsx +++ b/frontend/src/pages/Workflow2/Design/components/FlowCanvas.tsx @@ -152,8 +152,8 @@ const FlowCanvas: React.FC = ({ fitViewOptions={{ padding: 0.1, includeHiddenNodes: false, - minZoom: 0.5, - maxZoom: 1.5, + minZoom: 1.0, + maxZoom: 1.0, duration: 800, }} minZoom={0.1} diff --git a/frontend/src/pages/Workflow2/Design/components/NodeConfigModal.tsx b/frontend/src/pages/Workflow2/Design/components/NodeConfigModal.tsx new file mode 100644 index 00000000..4bfc14f4 --- /dev/null +++ b/frontend/src/pages/Workflow2/Design/components/NodeConfigModal.tsx @@ -0,0 +1,256 @@ +import React, { useState, useEffect } from 'react'; +import { Modal, Form, Input, Tabs, Card, Button, Space, message } from 'antd'; +import { SaveOutlined, ReloadOutlined } from '@ant-design/icons'; +import type { FlowNode, FlowNodeData } from '../types'; + +interface NodeConfigModalProps { + visible: boolean; + node: FlowNode | null; + onCancel: () => void; + onOk: (nodeId: string, updatedData: Partial) => void; +} + +const { TextArea } = Input; + +const NodeConfigModal: React.FC = ({ + visible, + node, + onCancel, + onOk +}) => { + const [form] = Form.useForm(); + const [loading, setLoading] = useState(false); + const [activeTab, setActiveTab] = useState('basic'); + + // 重置表单数据 + useEffect(() => { + if (visible && node) { + form.setFieldsValue({ + label: node.data.label, + description: node.data.nodeDefinition?.description || '', + // 基础配置 + timeout: node.data.configs?.timeout || 3600, + retryCount: node.data.configs?.retryCount || 0, + priority: node.data.configs?.priority || 'normal', + // 输入映射 + inputMapping: JSON.stringify(node.data.inputMapping || {}, null, 2), + // 输出映射 + outputMapping: JSON.stringify(node.data.outputMapping || {}, null, 2), + }); + } else { + form.resetFields(); + } + }, [visible, node, form]); + + const handleSubmit = async () => { + if (!node) return; + + try { + const values = await form.validateFields(); + setLoading(true); + + // 解析JSON字符串 + let inputMapping = {}; + let outputMapping = {}; + + try { + inputMapping = values.inputMapping ? JSON.parse(values.inputMapping) : {}; + } catch (error) { + message.error('输入映射JSON格式错误'); + return; + } + + try { + outputMapping = values.outputMapping ? JSON.parse(values.outputMapping) : {}; + } catch (error) { + message.error('输出映射JSON格式错误'); + return; + } + + const updatedData: Partial = { + label: values.label, + configs: { + ...node.data.configs, + timeout: values.timeout, + retryCount: values.retryCount, + priority: values.priority, + }, + inputMapping, + outputMapping, + }; + + onOk(node.id, updatedData); + message.success('节点配置保存成功'); + onCancel(); + } catch (error) { + console.error('保存节点配置失败:', error); + } finally { + setLoading(false); + } + }; + + const handleReset = () => { + form.resetFields(); + if (node) { + form.setFieldsValue({ + label: node.data.label, + description: node.data.nodeDefinition?.description || '', + timeout: 3600, + retryCount: 0, + priority: 'normal', + inputMapping: '{}', + outputMapping: '{}', + }); + } + }; + + const renderBasicConfig = () => ( + + + + + + +