diff --git a/vite-frontend/src/pages/node.tsx b/vite-frontend/src/pages/node.tsx index f548dda..383baf6 100644 --- a/vite-frontend/src/pages/node.tsx +++ b/vite-frontend/src/pages/node.tsx @@ -66,6 +66,11 @@ export default function NodePage() { }); const [errors, setErrors] = useState>({}); + // 安装命令相关状态 + const [installCommandModal, setInstallCommandModal] = useState(false); + const [installCommand, setInstallCommand] = useState(''); + const [currentNodeName, setCurrentNodeName] = useState(''); + const websocketRef = useRef(null); const reconnectTimerRef = useRef(null); const reconnectAttemptsRef = useRef(0); @@ -409,13 +414,20 @@ export default function NodePage() { try { const res = await getNodeInstallCommand(node.id); if (res.code === 0 && res.data) { - await navigator.clipboard.writeText(res.data); - toast.success('安装命令已复制到剪贴板'); + try { + await navigator.clipboard.writeText(res.data); + toast.success('安装命令已复制到剪贴板'); + } catch (copyError) { + // 复制失败,显示安装命令模态框 + setInstallCommand(res.data); + setCurrentNodeName(node.name); + setInstallCommandModal(true); + } } else { toast.error(res.msg || '获取安装命令失败'); } } catch (error) { - toast.error('复制失败,请手动复制'); + toast.error('获取安装命令失败'); } finally { setNodeList(prev => prev.map(n => n.id === node.id ? { ...n, copyLoading: false } : n @@ -423,6 +435,17 @@ export default function NodePage() { } }; + // 手动复制安装命令 + const handleManualCopy = async () => { + try { + await navigator.clipboard.writeText(installCommand); + toast.success('安装命令已复制到剪贴板'); + setInstallCommandModal(false); + } catch (error) { + toast.error('复制失败,请手动选择文本复制'); + } + }; + // 提交表单 const handleSubmit = async () => { if (!validateForm()) return; @@ -785,6 +808,58 @@ export default function NodePage() { + + {/* 安装命令模态框 */} + setInstallCommandModal(false)} + size="2xl" + scrollBehavior="inside" + > + + 安装命令 - {currentNodeName} + +
+

+ 请复制以下安装命令到服务器上执行: +

+
+