跳转页面
This commit is contained in:
+17
-1
@@ -27,6 +27,7 @@ const whitelist = externalLinkWhitelist.map((domain) => domain.toLowerCase());
|
|||||||
|
|
||||||
<div class="external-redirect-actions">
|
<div class="external-redirect-actions">
|
||||||
<a class="external-redirect-button is-primary" href="/" data-continue hidden>立即访问</a>
|
<a class="external-redirect-button is-primary" href="/" data-continue hidden>立即访问</a>
|
||||||
|
<button class="external-redirect-button" type="button" data-cancel hidden>取消跳转</button>
|
||||||
<a class="external-redirect-button" href="/" data-back>返回上一页</a>
|
<a class="external-redirect-button" href="/" data-back>返回上一页</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -53,7 +54,10 @@ const whitelist = externalLinkWhitelist.map((domain) => domain.toLowerCase());
|
|||||||
const ring = document.querySelector('[data-countdown-ring]');
|
const ring = document.querySelector('[data-countdown-ring]');
|
||||||
const continueLink = document.querySelector('[data-continue]');
|
const continueLink = document.querySelector('[data-continue]');
|
||||||
const backLink = document.querySelector('[data-back]');
|
const backLink = document.querySelector('[data-back]');
|
||||||
|
const cancelButton = document.querySelector('[data-cancel]');
|
||||||
const circumference = 2 * Math.PI * 52;
|
const circumference = 2 * Math.PI * 52;
|
||||||
|
let timer = 0;
|
||||||
|
let hasCanceled = false;
|
||||||
|
|
||||||
function setText(node, text) {
|
function setText(node, text) {
|
||||||
if (node) node.textContent = text;
|
if (node) node.textContent = text;
|
||||||
@@ -124,6 +128,7 @@ const whitelist = externalLinkWhitelist.map((domain) => domain.toLowerCase());
|
|||||||
setText(title, '即将离开本站');
|
setText(title, '即将离开本站');
|
||||||
setText(message, `目标域名不在白名单中,${remaining} 秒后将自动跳转。`);
|
setText(message, `目标域名不在白名单中,${remaining} 秒后将自动跳转。`);
|
||||||
countdownWrap.hidden = false;
|
countdownWrap.hidden = false;
|
||||||
|
cancelButton.hidden = false;
|
||||||
countdown.textContent = remaining;
|
countdown.textContent = remaining;
|
||||||
|
|
||||||
if (ring) {
|
if (ring) {
|
||||||
@@ -131,7 +136,18 @@ const whitelist = externalLinkWhitelist.map((domain) => domain.toLowerCase());
|
|||||||
ring.style.strokeDashoffset = '0';
|
ring.style.strokeDashoffset = '0';
|
||||||
}
|
}
|
||||||
|
|
||||||
const timer = window.setInterval(() => {
|
cancelButton?.addEventListener('click', () => {
|
||||||
|
hasCanceled = true;
|
||||||
|
window.clearInterval(timer);
|
||||||
|
cancelButton.hidden = true;
|
||||||
|
countdownWrap.hidden = true;
|
||||||
|
setText(statusLabel, '已取消');
|
||||||
|
setText(title, '已取消自动跳转');
|
||||||
|
setText(message, '自动跳转已停止,你可以继续访问目标地址,或返回上一页。');
|
||||||
|
});
|
||||||
|
|
||||||
|
timer = window.setInterval(() => {
|
||||||
|
if (hasCanceled) return;
|
||||||
remaining -= 1;
|
remaining -= 1;
|
||||||
countdown.textContent = remaining;
|
countdown.textContent = remaining;
|
||||||
setText(message, `目标域名不在白名单中,${remaining} 秒后将自动跳转。`);
|
setText(message, `目标域名不在白名单中,${remaining} 秒后将自动跳转。`);
|
||||||
|
|||||||
@@ -3156,6 +3156,7 @@ meting-js {
|
|||||||
.external-redirect-actions {
|
.external-redirect-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
margin-top: 28px;
|
margin-top: 28px;
|
||||||
}
|
}
|
||||||
@@ -3169,8 +3170,10 @@ meting-js {
|
|||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 9px 16px;
|
padding: 9px 16px;
|
||||||
color: var(--accent);
|
color: var(--accent);
|
||||||
|
font: inherit;
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
background: rgba(236, 253, 245, 0.68);
|
background: rgba(236, 253, 245, 0.68);
|
||||||
|
cursor: pointer;
|
||||||
transition:
|
transition:
|
||||||
color 0.2s ease,
|
color 0.2s ease,
|
||||||
background-color 0.2s ease,
|
background-color 0.2s ease,
|
||||||
|
|||||||
Reference in New Issue
Block a user