${pluginText("访问地址", "Access URL")}
${pluginText("设置 Gateway 管理页面地址,首页显示链接按钮;留空隐藏入口。", "Set the Gateway management URL to show a link on the overview. Leave blank to hide it.")}
`);
+ $("saveGatewayAccess").onclick = async () => {
+ const button = $("saveGatewayAccess"), message = $("gatewayAccessMessage");
+ const value = $("gatewayAccessUrl").value.trim();
+ if (value) {
+ try {
+ const url = new URL(value);
+ if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.pathname !== "/" || url.search || url.hash) throw Error();
+ } catch {
+ message.textContent = pluginText("请使用不含路径或账号密码的 HTTP(S) 根地址", "Use an HTTP(S) origin without paths or credentials");
+ message.className = "error"; return;
+ }
+ }
+ button.disabled = true;
+ try {
+ const result = await get("/api/v1/hosts", {method: "PUT", headers: {"Content-Type": "application/json"}, body: JSON.stringify({operation: "save", id: host.id, adapter_id: host.adapter_id, connection: {management_url: value}})});
+ appState.fleetHosts = result.hosts;
+ message.textContent = pluginText("已保存", "Saved"); message.className = "success";
+ } catch (error) { message.textContent = error.message; message.className = "error"; }
+ finally { button.disabled = false; }
+ };
+}
diff --git a/plugin/ui/overview.js b/plugin/ui/overview.js
index 08bcc9e..1c8e74d 100644
--- a/plugin/ui/overview.js
+++ b/plugin/ui/overview.js
@@ -8,10 +8,19 @@ import { bytes, formatUptime, meter } from "/assets/js/overview.js";
import { fanMetric } from "./hardware.js";
import { ownerName, rgbName } from "./schema.js";
+function managementLink(host) {
+ try {
+ const url = new URL(host.connection?.management_url);
+ if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) return "";
+ const label = appState.LANG === "zh" ? "打开 Gateway 管理界面" : "Open Gateway management";
+ return `