diff --git a/frontend/src/pages/agents/CreateAgent.tsx b/frontend/src/pages/agents/CreateAgent.tsx index 4acbfb2..de1974c 100644 --- a/frontend/src/pages/agents/CreateAgent.tsx +++ b/frontend/src/pages/agents/CreateAgent.tsx @@ -1,7 +1,7 @@ import { useState, useEffect } from "react"; import { useNavigate } from "react-router-dom"; -import { Box, Flex, Heading, Text, Code } from "@radix-ui/themes"; -import { Button, Card, Separator } from "@/components/ui"; +import { Box, Flex, Heading, Text, Code, TextField } from "@radix-ui/themes"; +import { Button, Card, Separator, Switch } from "@/components/ui"; import { ArrowLeftIcon, CopyIcon, @@ -25,6 +25,10 @@ const CreateAgent = () => { const [tokenCopied, setTokenCopied] = useState(false); const [installCommandCopied, setInstallCommandCopied] = useState(false); + // 代理功能的状态 + const [useProxy, setUseProxy] = useState(false); + const [customProxyUrl, setCustomProxyUrl] = useState("https://gh-proxy.com/"); + // 生成服务端验证的 token useEffect(() => { const fetchToken = async () => { @@ -60,10 +64,17 @@ const CreateAgent = () => { setTimeout(() => setTokenCopied(false), 2000); }; + // 根据是否使用代理生成安装脚本 URL + const getInstallScriptUrl = () => { + const baseUrl = "https://github.com/zaunist/xugou/blob/main/install-agent.sh"; + if (useProxy) { + return `${customProxyUrl}${baseUrl}`; + } + return baseUrl; + }; + // 生成并复制安装命令 - const installScriptUrl = - "https://gh-proxy.com/github.com/zaunist/xugou/blob/main/install-agent.sh"; - const oneLinerInstallCommand = `curl -sSL ${installScriptUrl} | bash -s -- --server ${serverUrl} --token ${token} --interval 60`; + const oneLinerInstallCommand = `curl -sSL ${getInstallScriptUrl()} | bash -s -- --server ${serverUrl} --token ${token} --interval 60`; const handleCopyInstallCommand = () => { navigator.clipboard.writeText(oneLinerInstallCommand); @@ -82,7 +93,7 @@ const CreateAgent = () => { - + {/* 提示信息 */} @@ -145,6 +156,30 @@ const CreateAgent = () => { + {/* 代理设置 */} + + + + + 启用 GitHub 代理 + + + {useProxy && ( + + 自定义代理地址 (可选): + setCustomProxyUrl(e.target.value)} + placeholder="例如: https://gh-proxy.com/" + /> + + )} + + @@ -153,7 +188,7 @@ const CreateAgent = () => { "一键安装命令 (Linux/macOS/Windows):" )} - {oneLinerInstallCommand} + {oneLinerInstallCommand}