From 11129cc3a0bd82116471c1839bb6b6768f02e601 Mon Sep 17 00:00:00 2001 From: dekun Date: Sat, 30 May 2026 17:59:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20iframe=20=E5=B7=A5=E5=85=B7=E6=A0=8F?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B0=E6=A0=87=E7=AD=BE=E9=A1=B5=E6=89=93?= =?UTF-8?q?=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在内嵌页工具栏「强制刷新」旁增加「新标签页」按钮,以 noopener 方式打开当前 iframe 地址,便于无法内嵌时在独立标签访问。 Co-authored-by: Cursor --- templates/index.html | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/templates/index.html b/templates/index.html index bc9d1d4..92872c6 100644 --- a/templates/index.html +++ b/templates/index.html @@ -156,6 +156,14 @@ > 强制刷新 +
@@ -208,6 +216,7 @@ var cards = document.querySelectorAll(".service-card[data-url]"); var btnRefresh = document.getElementById("frame-refresh"); var btnForceRefresh = document.getElementById("frame-force-refresh"); + var btnOpenTab = document.getElementById("frame-open-tab"); var btnBack = document.getElementById("frame-back-overview"); var btnBackHub = document.getElementById("frame-back-hub"); var btnHubLogin = document.getElementById("frame-hub-login"); @@ -626,6 +635,31 @@ }; } + function getCurrentFrameUrl() { + var u = ""; + try { + if ( + frame.contentWindow && + frame.contentWindow.location && + frame.contentWindow.location.href && + frame.contentWindow.location.href !== "about:blank" + ) { + u = frame.contentWindow.location.href; + } + } catch (e) {} + if (!u || u === "about:blank") { + u = frame.src || currentOpenUrl || currentBaseUrl; + } + if (!u || u === "about:blank") return ""; + return u; + } + + function openInNewTab() { + var u = getCurrentFrameUrl(); + if (!u) return; + window.open(u, "_blank", "noopener,noreferrer"); + } + function showDashboard() { currentBaseUrl = ""; currentOpenUrl = ""; @@ -723,6 +757,12 @@ forceReloadUrl(); }); + if (btnOpenTab) { + btnOpenTab.addEventListener("click", function () { + openInNewTab(); + }); + } + btnBack.addEventListener("click", function () { showDashboard(); });