From 80b9deb32eed41a5f1edf80eff400b0dfe65eff5 Mon Sep 17 00:00:00 2001 From: Charles Chin Date: Sun, 17 Nov 2024 12:41:14 +0800 Subject: [PATCH] feat: redirect ref --- layouts/_default/go.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/layouts/_default/go.html b/layouts/_default/go.html index 0746bff0eb4..7b3353f0832 100644 --- a/layouts/_default/go.html +++ b/layouts/_default/go.html @@ -56,10 +56,15 @@

try { const target = atob(encodedTarget); // 使用 atob 进行 Base64 解码 const decodedTarget = decodeURIComponent(target); - document.getElementById('target-link').href = decodedTarget; - document.getElementById('direct-link').href = decodedTarget; + + // 检查目标 URL 是否已经包含查询字符串 + const hasQueryString = decodedTarget.includes('?'); + const separator = hasQueryString ? '&' : '?'; + + document.getElementById('target-link').href = decodedTarget + separator + 'ref=www.eallion.com'; + document.getElementById('direct-link').href = decodedTarget + separator + 'ref=www.eallion.com'; document.getElementById('redirect-link').textContent = decodedTarget; // 在新增的元素中显示原地址 - document.getElementById('redirect-link').href = decodedTarget; + document.getElementById('redirect-link').href = decodedTarget + separator + 'ref=www.eallion.com'; } catch (e) { document.getElementById('redirect-link').textContent = '未指定重定向目标。'; }