Skip to content

Commit

Permalink
feat: redirect ref
Browse files Browse the repository at this point in the history
  • Loading branch information
eallion committed Nov 17, 2024
1 parent 62d646d commit 80b9deb
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions layouts/_default/go.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ <h2 class="mt-0 mb-8 text-2xl text-neutral-800 text-shadow-white">
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 = '未指定重定向目标。';
}
Expand Down

0 comments on commit 80b9deb

Please sign in to comment.