fix: dynamically resolve active hostname in guide and connect views

This commit is contained in:
Hitonabi
2026-06-25 23:08:54 +02:00
parent e9fb72fdc7
commit b6af1c1b4a
4 changed files with 31 additions and 18 deletions
+7 -1
View File
@@ -4,7 +4,13 @@ import { api, type ConnectResp } from "@/lib/api"
import { cn } from "@/lib/utils"
export function ConnectView() {
const [host, setHost] = useState(localStorage.getItem("mc_host") || "192.168.178.151")
const [host, setHost] = useState(() => {
const saved = localStorage.getItem("mc_host")
if (saved) return saved
const hn = window.location.hostname
if (hn && hn !== "localhost" && hn !== "127.0.0.1") return hn
return "192.168.178.151"
})
const [mcpPath, setMcpPath] = useState(localStorage.getItem("mc_mcp_path") || "")
const [data, setData] = useState<ConnectResp | null>(null)
const [active, setActive] = useState("cline")