更换到Astro #9
+21
-1
@@ -27,7 +27,7 @@ const whitelist = externalLinkWhitelist.map((domain) => domain.toLowerCase());
|
||||
|
||||
<div class="external-redirect-actions">
|
||||
<a class="external-redirect-button is-primary" href="/" data-continue hidden>立即访问</a>
|
||||
<a class="external-redirect-button" href="/">返回首页</a>
|
||||
<a class="external-redirect-button" href="/" data-back>返回上一页</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -42,6 +42,7 @@ const whitelist = externalLinkWhitelist.map((domain) => domain.toLowerCase());
|
||||
(() => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const rawUrl = params.get('url') || params.get('target') || params.get('to') || '';
|
||||
const rawFrom = params.get('from') || '';
|
||||
const title = document.querySelector('[data-title]');
|
||||
const message = document.querySelector('[data-message]');
|
||||
const statusLabel = document.querySelector('[data-status-label]');
|
||||
@@ -51,6 +52,7 @@ const whitelist = externalLinkWhitelist.map((domain) => domain.toLowerCase());
|
||||
const countdown = document.querySelector('[data-countdown]');
|
||||
const ring = document.querySelector('[data-countdown-ring]');
|
||||
const continueLink = document.querySelector('[data-continue]');
|
||||
const backLink = document.querySelector('[data-back]');
|
||||
const circumference = 2 * Math.PI * 52;
|
||||
|
||||
function setText(node, text) {
|
||||
@@ -71,6 +73,24 @@ const whitelist = externalLinkWhitelist.map((domain) => domain.toLowerCase());
|
||||
setText(message, text);
|
||||
}
|
||||
|
||||
let returnUrl = '/';
|
||||
try {
|
||||
const fromUrl = new URL(rawFrom, window.location.origin);
|
||||
if (fromUrl.origin === window.location.origin && fromUrl.pathname !== window.location.pathname) {
|
||||
returnUrl = `${fromUrl.pathname}${fromUrl.search}${fromUrl.hash}`;
|
||||
}
|
||||
} catch {
|
||||
returnUrl = '/';
|
||||
}
|
||||
|
||||
if (backLink) backLink.href = returnUrl;
|
||||
|
||||
backLink?.addEventListener('click', (event) => {
|
||||
if (window.history.length <= 1) return;
|
||||
event.preventDefault();
|
||||
window.history.back();
|
||||
});
|
||||
|
||||
let destination;
|
||||
try {
|
||||
destination = new URL(rawUrl);
|
||||
|
||||
+1
-1
@@ -2316,7 +2316,7 @@ meting-js {
|
||||
position: relative;
|
||||
width: 112px;
|
||||
height: 112px;
|
||||
margin-top: 26px;
|
||||
margin: 26px auto 0;
|
||||
}
|
||||
|
||||
.external-redirect-countdown svg {
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
const redirectUrl = `${redirectPath}?url=${encodeURIComponent(externalUrl)}`;
|
||||
const redirectUrl = `${redirectPath}?url=${encodeURIComponent(externalUrl)}&from=${encodeURIComponent(window.location.href)}`;
|
||||
const target = anchor.getAttribute('target');
|
||||
|
||||
if (target && target !== '_self') {
|
||||
|
||||
Reference in New Issue
Block a user