This commit is contained in:
Daniel
2026-04-28 19:16:27 +08:00
parent 6de7e782fc
commit c234fe64d6
13 changed files with 229 additions and 31 deletions

36
app/static/guide.js Normal file
View File

@@ -0,0 +1,36 @@
const guideGetServerIpBtn = document.getElementById("getServerIpBtn");
async function showGuideAlert(message, title = "提示") {
if (typeof window.uiAlert === "function") {
await window.uiAlert(message, title);
return;
}
window.alert(message);
}
if (guideGetServerIpBtn) {
guideGetServerIpBtn.addEventListener("click", async () => {
const idleText = "获取服务器IP";
guideGetServerIpBtn.disabled = true;
guideGetServerIpBtn.textContent = "获取中...";
try {
const res = await fetch("/api/tools/server-ip");
const data = await res.json();
if (!res.ok || !data.ok) {
await showGuideAlert((data && data.detail) || "获取服务器IP失败请稍后重试", "获取失败");
return;
}
const ip = String(data.ip || "").trim();
if (!ip) {
await showGuideAlert("服务器IP为空请稍后重试", "获取失败");
return;
}
await showGuideAlert(`当前服务器IP${ip}`, "API IP白名单");
} catch {
await showGuideAlert("获取服务器IP失败请稍后重试", "获取失败");
} finally {
guideGetServerIpBtn.disabled = false;
guideGetServerIpBtn.textContent = idleText;
}
});
}