diff --git a/src/App.tsx b/src/App.tsx index 43656c2..e1b8774 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -124,7 +124,10 @@ function FlowContent(): ReactNode { setNodes((prev) => prev.map((node) => { if (node.data.id === editingNode?.id) { - node.data = {...node.data, ...updatedData} + return { + ...node, + data: {...node.data, ...updatedData} + } } return node; }) diff --git a/src/components/NodeEditor.tsx b/src/components/NodeEditor.tsx index 8c42a77..0bf8de8 100644 --- a/src/components/NodeEditor.tsx +++ b/src/components/NodeEditor.tsx @@ -23,6 +23,14 @@ class Validation { function Validate(updateData : NodeDataUpdate, settings : Settings) : Validation { const errors: string[] = []; + if(!updateData.label) { + errors.push("Label不能是空"); + } + + if(!updateData.privateKey) { + errors.push("privateKey不能是空"); + } + const ipv4Subnet = settings.ipv4Subnet; const ipv4Address = updateData.ipv4Address; if(ipv4Subnet) { diff --git a/src/components/SettingsEditor.tsx b/src/components/SettingsEditor.tsx index 45ae66f..016cf69 100644 --- a/src/components/SettingsEditor.tsx +++ b/src/components/SettingsEditor.tsx @@ -83,11 +83,8 @@ export default function SettingsEditor({ min="30000" max="49151" step="1" - value={listenPort} - onChange={e => { - const value = e.target.valueAsNumber; - setListenPort(isNaN(value) ? 38894 : value); - }} + value={listenPort || ""} + onChange={e => setListenPort(e.target.valueAsNumber)} />