From 2cc584713f03a7a1e7231f6b64f11d6fe3675635 Mon Sep 17 00:00:00 2001 From: TaskPool Date: Thu, 6 Aug 2026 14:37:43 +0800 Subject: [PATCH] fix(NodeSwitcher): use custom dropdown instead of native select for consistent styling --- web/src/components/business/NodeSwitcher.tsx | 89 +++++++++++++------- 1 file changed, 58 insertions(+), 31 deletions(-) diff --git a/web/src/components/business/NodeSwitcher.tsx b/web/src/components/business/NodeSwitcher.tsx index f04ab65..5e6806f 100644 --- a/web/src/components/business/NodeSwitcher.tsx +++ b/web/src/components/business/NodeSwitcher.tsx @@ -14,6 +14,7 @@ export function NodeSwitcher() { const [nodes, setNodes] = useState([]) const [selected, setSelected] = useState(activeInterconnectNodeId || 'local') const [isMaster, setIsMaster] = useState(false) + const [open, setOpen] = useState(false) const fetchNodes = useCallback(async () => { try { @@ -73,38 +74,64 @@ export function NodeSwitcher() { if (!isMaster) return null + const handleSelect = (val: string) => { + setSelected(val) + setOpen(false) + if (val === 'local') { + setActiveInterconnectNodeId('') + } else { + const name = nodes.find((n) => n.id === val)?.name || '' + setActiveInterconnectNodeId(val, name) + } + window.location.reload() + } + + const allOptions = [ + { value: 'local', label: '本机节点' }, + ...nodes.map((n) => ({ value: n.id, label: n.name })), + ] + + const currentLabel = allOptions.find((o) => o.value === selected)?.label || '本机节点' + return ( -
- - + + {currentLabel} + + + {open && ( +
+ {allOptions.map((opt) => ( + + ))} +
+ )} + + {open && ( +
setOpen(false)} /> + )}
) -} +} \ No newline at end of file