From f3bdb07e3d64c51959262978e9f61809f75323f8 Mon Sep 17 00:00:00 2001
From: rain <982766701@qq.com>
Date: Fri, 24 Jul 2026 18:19:33 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B7=B3=E8=BD=AC=E6=97=B6?=
=?UTF-8?q?=E6=89=93=E5=BC=80=E6=96=B0=E7=AA=97=E5=8F=A3=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config.js | 83 ++++++++++++++++++++++++++++++++
html/apply.html | 2 +-
html/c.html | 8 +--
html/chongzhi.html | 2 +-
html/fabumianfeiwenzhang.html | 6 +--
html/fufei.html | 2 +-
html/jine.html | 6 +--
html/login.html | 2 +-
html/mianfei.html | 6 +--
html/mianfeishoucang.html | 2 +-
html/open-browser.html | 5 +-
html/reg.html | 7 +--
html/repwd.html | 2 +-
html/social-callback.html | 4 +-
html/tixian.html | 2 +-
html/tixianlist.html | 2 +-
html/tuiguang.html | 2 +-
html/upgrade.html | 1 +
html/usercenter.html | 18 +++----
public/js/fufei-3dyjs-publish.js | 4 +-
utils/ApiClient.js | 6 +--
utils/CommonUtil.js | 6 +--
22 files changed, 132 insertions(+), 46 deletions(-)
diff --git a/config.js b/config.js
index f709997..47e6b80 100644
--- a/config.js
+++ b/config.js
@@ -33,3 +33,86 @@ window.CURRENT_ENV = (function () {
// 获取当前环境配置
window.CURRENT_CONFIG = window.ENV[window.CURRENT_ENV];
+
+window.NavigationUtil = (function (window, document) {
+ const blockedProtocols = /^(?:javascript|data|vbscript|mailto|tel):/i;
+
+ function shouldOpenInNewTab(anchor) {
+ const href = (anchor.getAttribute('href') || '').trim();
+
+ return href && href !== '#' && !href.startsWith('#') &&
+ !anchor.hasAttribute('download') && !blockedProtocols.test(href);
+ }
+
+ function prepareAnchor(anchor) {
+ if (!anchor || anchor.tagName !== 'A' || !shouldOpenInNewTab(anchor)) {
+ return;
+ }
+
+ if (anchor.target !== '_blank') {
+ anchor.target = '_blank';
+ }
+
+ const relTokens = (anchor.getAttribute('rel') || '').split(/\s+/).filter(Boolean);
+
+ if (!relTokens.includes('noopener')) {
+ anchor.setAttribute('rel', [...relTokens, 'noopener'].join(' '));
+ }
+ }
+
+ function prepareAnchors(root) {
+ if (root.nodeType === 1 && root.matches('a[href]')) {
+ prepareAnchor(root);
+ }
+
+ root.querySelectorAll('a[href]').forEach(prepareAnchor);
+ }
+
+ function installLinkTargeting() {
+ prepareAnchors(document);
+
+ new MutationObserver((mutations) => {
+ mutations.forEach((mutation) => {
+ if (mutation.type === 'attributes') {
+ prepareAnchor(mutation.target);
+ return;
+ }
+
+ mutation.addedNodes.forEach((node) => {
+ if (node.nodeType === 1) {
+ prepareAnchors(node);
+ }
+ });
+ });
+ }).observe(document.documentElement, {
+ subtree: true,
+ childList: true,
+ attributes: true,
+ attributeFilter: ['href', 'target', 'download']
+ });
+ }
+
+ if (document.readyState === 'loading') {
+ document.addEventListener('DOMContentLoaded', installLinkTargeting, { once: true });
+ } else {
+ installLinkTargeting();
+ }
+
+ return {
+ open(url) {
+ const destination = String(url || '').trim();
+
+ if (!destination) {
+ return null;
+ }
+
+ const openedWindow = window.open(destination, '_blank', 'noopener');
+
+ if (openedWindow) {
+ openedWindow.opener = null;
+ }
+
+ return openedWindow;
+ }
+ };
+})(window, document);
diff --git a/html/apply.html b/html/apply.html
index 683ecf7..f197ec6 100644
--- a/html/apply.html
+++ b/html/apply.html
@@ -373,7 +373,7 @@
"资料上传成功,请等待审核通过",
{ icon: 1, time: 1800 },
function () {
- window.location.href = "usercenter.html";
+ NavigationUtil.open("usercenter.html");
}
);
} else {
diff --git a/html/c.html b/html/c.html
index c8af7fb..b443123 100644
--- a/html/c.html
+++ b/html/c.html
@@ -3,12 +3,12 @@
+
神彩算 - 免费文章收藏
-
@@ -137,7 +137,7 @@
);
});
} else {
- window.location.href = "login.html";
+ NavigationUtil.open("login.html");
return;
}
}
@@ -157,7 +157,7 @@
function loadCollections() {
const token = localStorage.getItem("token");
if (!token) {
- window.location.href = "login.html";
+ NavigationUtil.open("login.html");
return;
}
diff --git a/html/chongzhi.html b/html/chongzhi.html
index 21a70c2..fe89e64 100644
--- a/html/chongzhi.html
+++ b/html/chongzhi.html
@@ -246,7 +246,7 @@
},
);
} else {
- window.location.href = "login.html";
+ NavigationUtil.open("login.html");
}
}
diff --git a/html/fabumianfeiwenzhang.html b/html/fabumianfeiwenzhang.html
index 18205e0..a833845 100644
--- a/html/fabumianfeiwenzhang.html
+++ b/html/fabumianfeiwenzhang.html
@@ -254,7 +254,7 @@
"您还不是实习或正式专家,暂不能发布文章。",
{ title: "暂无权限" },
function () {
- window.location.href = "apply.html";
+ NavigationUtil.open("apply.html");
},
);
return;
@@ -284,7 +284,7 @@
});
return;
}
- window.location.href = targetHref;
+ NavigationUtil.open(targetHref);
});
});
});
@@ -525,7 +525,7 @@
"发布成功,请等待审核",
{ icon: 1, time: 1600 },
function () {
- window.location.href = "index.html";
+ NavigationUtil.open("index.html");
},
);
} else {
diff --git a/html/fufei.html b/html/fufei.html
index 64e3a36..c571303 100644
--- a/html/fufei.html
+++ b/html/fufei.html
@@ -217,7 +217,7 @@
function logout() {
localStorage.removeItem("token");
- window.location.href = "login.html";
+ NavigationUtil.open("login.html");
}
function renderLoginState() {
diff --git a/html/jine.html b/html/jine.html
index a2a0c55..a7efa05 100644
--- a/html/jine.html
+++ b/html/jine.html
@@ -210,7 +210,7 @@
{ btn: ["去登录", "取消"] },
function (index) {
layui.layer.close(index);
- window.location.href = "login.html";
+ NavigationUtil.open("login.html");
},
);
});
@@ -566,11 +566,11 @@
ApiClient.post(ApiClient.API.authLogout, {})
.then(function () {
localStorage.removeItem("token");
- window.location.href = "login.html";
+ NavigationUtil.open("login.html");
})
.catch(function () {
localStorage.removeItem("token");
- window.location.href = "login.html";
+ NavigationUtil.open("login.html");
});
}
diff --git a/html/login.html b/html/login.html
index 1f3f2a9..d8b8579 100644
--- a/html/login.html
+++ b/html/login.html
@@ -316,7 +316,7 @@
}
function redirectAfterLogin() {
- window.location.href = getLoginRedirectUrl();
+ NavigationUtil.open(getLoginRedirectUrl());
}
function bindReferralThenRedirect() {
diff --git a/html/mianfei.html b/html/mianfei.html
index 2dad52e..ae637f1 100644
--- a/html/mianfei.html
+++ b/html/mianfei.html
@@ -497,7 +497,7 @@
{ icon: 3, title: "提示" },
function (index) {
layui.layer.close(index);
- window.location.href = "login.html";
+ NavigationUtil.open("login.html");
},
);
return;
@@ -533,7 +533,7 @@
{ icon: 3, title: "提示" },
function (index) {
layui.layer.close(index);
- window.location.href = "login.html";
+ NavigationUtil.open("login.html");
},
);
return;
@@ -671,7 +671,7 @@
{ icon: 3, title: "提示" },
function (index) {
layui.layer.close(index);
- window.location.href = "login.html";
+ NavigationUtil.open("login.html");
},
);
return;
diff --git a/html/mianfeishoucang.html b/html/mianfeishoucang.html
index 72d46d3..22d90c3 100644
--- a/html/mianfeishoucang.html
+++ b/html/mianfeishoucang.html
@@ -223,7 +223,7 @@
function checkLogin() {
if (!CommonUtil.getAuthToken()) {
- window.location.href = "login.html";
+ NavigationUtil.open("login.html");
return;
}
diff --git a/html/open-browser.html b/html/open-browser.html
index 580fca7..322e07a 100644
--- a/html/open-browser.html
+++ b/html/open-browser.html
@@ -41,6 +41,7 @@
color: #111827;
}
+
@@ -59,9 +60,9 @@
if (!inApp && location.search.indexOf(prefix) === 0) {
const target = location.search.slice(prefix.length);
if (target && target.charAt(0) === "/" && target.indexOf("//") !== 0) {
- location.replace(target);
+ NavigationUtil.open(target);
}
}
-