diff --git a/src/App.tsx b/src/App.tsx index bb9c9dd..66f8ab1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -111,7 +111,7 @@ function FlowContent(): ReactNode { const handleUpdateNode = (updatedData: NodeData): void => { setNodes((prev) => prev.map((node) => { - if (node.data.label === editingNode?.label) { + if (node.data.id === editingNode?.id) { return { ...node, data: updatedData }; } return node; diff --git a/src/TODO.md b/src/TODO.md new file mode 100644 index 0000000..ba3b95b --- /dev/null +++ b/src/TODO.md @@ -0,0 +1,9 @@ +## 产品基本功能实现待办事项 + +- [x] 完成节点的编辑窗口 +- [ ] 完成边的编辑窗口 +- [ ] 完成全局设置编辑窗口以及相关联动 +- [ ] 实现配置生成逻辑,并验证有效 +- [ ] 实现配置保存和加载功能 +- [ ] 实现加密功能(完全加密和只加密私钥) +- [ ] 完成!奖励自己 diff --git a/src/components/NodeEditor.tsx b/src/components/NodeEditor.tsx index 0c4abc3..ef75323 100644 --- a/src/components/NodeEditor.tsx +++ b/src/components/NodeEditor.tsx @@ -3,7 +3,17 @@ import { NodeData, Settings } from '../types/graph'; import { generateWireGuardPrivateKey } from '../utils/wireguardConfig' import './NodeEditor.css'; import Folder from './Folder' -import { randomBytes } from 'tweetnacl'; + + +interface Validation { + isValid: boolean, + errors: string[] +} + +function validateNodeConfig(formData : NodeData) : Validation { + // todo + return {isValid : true, errors: []} +} interface NodeEditorProps { node: NodeData; @@ -30,16 +40,14 @@ export default function NodeEditor({ }; const handleSave = (): void => { - setErrors(["123"]) - // const validation = validateNodeConfig(formData); - // if (!validation.isValid) { - // setErrors(validation.errors); - // return; - // } - - // setErrors([]); - // onUpdate(formData); - // onClose(); + const validation = validateNodeConfig(formData); + if (!validation.isValid) { + setErrors(validation.errors); + return; + } + setErrors([]); + onUpdate(formData); + onClose(); }; const handleGenerateKey = (): void => {