友链申请卡片改挂置顶评论 + 弹窗挂 body 加毛玻璃
Deploy to Production / pre-check (push) Successful in 28s
Deploy to Production / build (push) Successful in 2m41s
Deploy to Production / deploy-edgeone (push) Successful in 3m47s
Deploy to Production / finalize (push) Successful in 27s
Deploy to Production / notify-failure (push) Skipped

- 置顶评论卡片化:管理员置顶且内容含「友链自助申请」的评论,
  整条解析成申请入口卡片(隐藏昵称/页脚,渐变虚线卡片,点击打开
  申请弹窗),其余置顶评论不受影响
- 弹窗 DOM 动态挂 document.body:评论容器带 transform 动画会把
  position:fixed 劫持成相对定位,导致遮罩/表单跟着容器变形——
  挂 body 彻底规避
- 遮罩加 backdrop-filter 毛玻璃(GPU 合成,不影响页面性能)
This commit is contained in:
QunLIn committed 2026-10-03 13:08:14 +08:00
1 parent 5fcbd2a7b6
commit da1a77a313
2 files changed
+106 -45

No files matched your search

+57
View File
@@ -686,6 +686,63 @@ artalk.on('comment-rendered', function(node) {
injectBadge(nickEl, 'atk-rank-badge', data.rank_name, tip, data.rank_color || '', data.rank_bg || ''); injectBadge(nickEl, 'atk-rank-badge', data.rank_name, tip, data.rank_color || '', data.rank_bg || '');
} }
} catch (e) { /* 徽章注入失败不影响评论 */ } } catch (e) { /* 徽章注入失败不影响评论 */ }
// ── 置顶评论卡片化:管理员置顶且内容含「友链自助申请」的评论,
// 整条解析成申请入口卡片(点击打开申请弹窗),其余置顶评论不受影响。
try {
var d2 = null;
if (node && typeof node.getData === 'function') d2 = node.getData();
else if (node && node.comment && typeof node.comment.getData === 'function') d2 = node.comment.getData();
else d2 = node;
var el2 = null;
if (node && node.$el) el2 = node.$el;
else if (node && typeof node.getEl === 'function') el2 = node.getEl();
if (!d2 || !d2.is_pinned || !el2) return;
var content = String(d2.content || '');
if (content.indexOf('友链自助申请') === -1) return;
if (el2.querySelector('.atk-fl-apply')) return;
el2.classList.add('atk-fl-apply');
el2.style.cursor = 'pointer';
el2.title = '点击申请友链';
// 隐藏评论常规元素(昵称行/页脚操作),整条变成一张卡片
var hd = el2.querySelector('.atk-header');
var ft = el2.querySelector('.atk-footer');
if (hd) hd.style.display = 'none';
if (ft) ft.style.display = 'none';
var meta = el2.querySelector('.atk-meta');
if (meta) meta.style.display = 'none';
var main = el2.querySelector('.atk-main') || el2;
var contentEl = main.querySelector('.atk-content');
var card = document.createElement('div');
card.className = 'atk-fl-apply';
card.style.cssText = 'display:flex;align-items:center;gap:12px;padding:16px 18px;margin:6px 0;' +
'background:linear-gradient(135deg,rgba(47,158,99,.08),rgba(47,158,99,.02));' +
'border:1px dashed rgba(47,158,99,.45);border-radius:10px;transition:border-color .2s,transform .2s;';
card.innerHTML =
'<span style="flex:none;width:40px;height:40px;border-radius:10px;background:rgba(47,158,99,.12);' +
'display:flex;align-items:center;justify-content:center;font-size:20px">🔗</span>' +
'<span style="flex:1;min-width:0">' +
'<span style="display:block;font-size:15px;font-weight:600;color:#2f9e63">友链自助申请</span>' +
'<span style="display:block;font-size:12px;color:#8a8e98;margin-top:2px">想和我交换友链?点这里填写申请,审核结果会邮件通知你</span>' +
'</span>' +
'<span style="flex:none;color:#2f9e63;font-size:18px">›</span>';
if (contentEl) {
contentEl.innerHTML = '';
contentEl.appendChild(card);
contentEl.style.cursor = 'pointer';
} else {
main.appendChild(card);
}
el2.addEventListener('click', function () {
if (window.flApplyOpenModal) window.flApplyOpenModal();
});
el2.addEventListener('mouseenter', function () { card.style.borderColor = 'rgba(47,158,99,.8)'; });
el2.addEventListener('mouseleave', function () { card.style.borderColor = 'rgba(47,158,99,.45)'; });
} catch (e) { /* 卡片化失败不影响评论 */ }
}); });
artalk.on('list-loaded', function() { artalk.on('list-loaded', function() {
+49 -45
View File
@@ -11,18 +11,6 @@
- 图标:{{ .Site.Params.message_info.icon | default .Site.Params.author.avatar }} - 图标:{{ .Site.Params.message_info.icon | default .Site.Params.author.avatar }}
</div> </div>
</div> </div>
<!-- 友链自助申请入口(卡片样式与文章外链卡片一致) -->
{{ $rssBase := site.Params.rssapi.base | default "https://api.200181.xyz" }}
<a class="link-card" id="flApplyOpen" href="javascript:void(0)" style="margin:14px 0;text-decoration:none">
<img class="link-card-icon" src="/favicon.ico" alt="" loading="lazy"
onerror="this.src='{{ site.Params.author.avatar | default "/favicon.ico" }}';this.onerror=null;">
<span class="link-card-body">
<span class="link-card-title">友链自助申请</span>
<span style="font-size:12px;color:var(--at-color-meta,#8a94a6)">想和我交换友链?点这里填写申请,审核结果会邮件通知你</span>
</span>
</a>
<hr class="uk-divider-icon"> <hr class="uk-divider-icon">
<div class="comments-area"> <div class="comments-area">
<!-- 评论区内容 --> <!-- 评论区内容 -->
@@ -32,42 +20,46 @@
</div> </div>
<!-- 友链申请弹窗 -->
<div id="flApplyMask" hidden style="position:fixed;inset:0;z-index:9999;background:rgba(20,32,55,.45);display:flex;align-items:center;justify-content:center;padding:16px">
<div style="background:#fff;color:#253244;border-radius:10px;max-width:420px;width:100%;padding:22px;box-shadow:0 12px 32px rgba(20,32,55,.2);max-height:90vh;overflow:auto">
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:14px">
<b style="font-size:16px">友链自助申请</b>
<span id="flApplyClose" style="cursor:pointer;color:#8a94a6;font-size:20px;line-height:1" title="关闭">×</span>
</div>
<label style="display:block;margin-bottom:10px"><span style="display:block;font-size:12px;color:#8a94a6;margin-bottom:4px">站点名称 *</span>
<input id="flName" style="width:100%;box-sizing:border-box;padding:8px 10px;border:1px solid #e7e9ee;border-radius:6px;font-size:14px" placeholder="我的小站"></label>
<label style="display:block;margin-bottom:10px"><span style="display:block;font-size:12px;color:#8a94a6;margin-bottom:4px">站点链接 *</span>
<input id="flUrl" style="width:100%;box-sizing:border-box;padding:8px 10px;border:1px solid #e7e9ee;border-radius:6px;font-size:14px" placeholder="https://example.com"></label>
<label style="display:block;margin-bottom:10px"><span style="display:block;font-size:12px;color:#8a94a6;margin-bottom:4px">订阅地址(RSS/Atom)*</span>
<input id="flFeed" style="width:100%;box-sizing:border-box;padding:8px 10px;border:1px solid #e7e9ee;border-radius:6px;font-size:14px" placeholder="https://example.com/feed"></label>
<label style="display:block;margin-bottom:10px"><span style="display:block;font-size:12px;color:#8a94a6;margin-bottom:4px">邮箱 *(接收审核结果)</span>
<input id="flEmail" type="email" style="width:100%;box-sizing:border-box;padding:8px 10px;border:1px solid #e7e9ee;border-radius:6px;font-size:14px" placeholder="you@example.com"></label>
<label style="display:block;margin-bottom:14px"><span style="display:block;font-size:12px;color:#8a94a6;margin-bottom:4px">站点简介(选填)</span>
<textarea id="flDesc" rows="2" style="width:100%;box-sizing:border-box;padding:8px 10px;border:1px solid #e7e9ee;border-radius:6px;font-size:14px;resize:vertical"></textarea></label>
<div id="flMsg" hidden style="font-size:13px;margin-bottom:10px"></div>
<button id="flSubmit" class="uk-button uk-button-primary" style="width:100%;background:#2f9e63;border:none;color:#fff;padding:10px;border-radius:6px;font-size:14px;cursor:pointer">提交申请</button>
</div>
</div>
<script> <script>
/* 友链自助申请:弹窗动态挂到 document.body(评论容器带 transform 动画,
会把 position:fixed 劫持成相对定位,导致遮罩/表单跟着容器变形——
挂 body 彻底规避),遮罩用 backdrop-filter 毛玻璃(GPU 合成,不卡页面)。 */
(function () { (function () {
var BASE = '{{ $rssBase }}'; var BASE = '{{ $rssBase := site.Params.rssapi.base | default "https://api.200181.xyz" }}{{ $rssBase }}';
var open = document.getElementById('flApplyOpen'); var mask = null;
var mask = document.getElementById('flApplyMask');
if (!open || !mask) return; function buildModal() {
function close() { mask.hidden = true; } if (document.getElementById('flApplyMask')) return document.getElementById('flApplyMask');
open.addEventListener('click', function () { mask = document.createElement('div');
mask.hidden = false; mask.id = 'flApplyMask';
var msg = document.getElementById('flMsg'); mask.setAttribute('hidden', '');
msg.hidden = true; mask.style.cssText = 'position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;padding:16px;' +
}); 'background:rgba(15,23,42,.35);-webkit-backdrop-filter:blur(10px) saturate(1.3);backdrop-filter:blur(10px) saturate(1.3);';
document.getElementById('flApplyClose').addEventListener('click', close); mask.innerHTML =
'<div style="background:#fff;color:#253244;border-radius:12px;max-width:420px;width:100%;padding:22px;' +
'box-shadow:0 16px 48px rgba(15,23,42,.25);max-height:88vh;overflow:auto">' +
'<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:14px">' +
'<b style="font-size:16px">友链自助申请</b>' +
'<span id="flApplyClose" style="cursor:pointer;color:#8a94a6;font-size:22px;line-height:1" title="关闭">×</span>' +
'</div>' +
'<label style="display:block;margin-bottom:10px"><span style="display:block;font-size:12px;color:#8a94a6;margin-bottom:4px">站点名称 *</span>' +
'<input id="flName" style="width:100%;box-sizing:border-box;padding:8px 10px;border:1px solid #e7e9ee;border-radius:6px;font-size:14px" placeholder="我的小站"></label>' +
'<label style="display:block;margin-bottom:10px"><span style="display:block;font-size:12px;color:#8a94a6;margin-bottom:4px">站点链接 *</span>' +
'<input id="flUrl" style="width:100%;box-sizing:border-box;padding:8px 10px;border:1px solid #e7e9ee;border-radius:6px;font-size:14px" placeholder="https://example.com"></label>' +
'<label style="display:block;margin-bottom:10px"><span style="display:block;font-size:12px;color:#8a94a6;margin-bottom:4px">订阅地址(RSS/Atom)*</span>' +
'<input id="flFeed" style="width:100%;box-sizing:border-box;padding:8px 10px;border:1px solid #e7e9ee;border-radius:6px;font-size:14px" placeholder="https://example.com/feed"></label>' +
'<label style="display:block;margin-bottom:10px"><span style="display:block;font-size:12px;color:#8a94a6;margin-bottom:4px">邮箱 *(接收审核结果)</span>' +
'<input id="flEmail" type="email" style="width:100%;box-sizing:border-box;padding:8px 10px;border:1px solid #e7e9ee;border-radius:6px;font-size:14px" placeholder="you@example.com"></label>' +
'<label style="display:block;margin-bottom:14px"><span style="display:block;font-size:12px;color:#8a94a6;margin-bottom:4px">站点简介(选填)</span>' +
'<textarea id="flDesc" rows="2" style="width:100%;box-sizing:border-box;padding:8px 10px;border:1px solid #e7e9ee;border-radius:6px;font-size:14px;resize:vertical"></textarea></label>' +
'<div id="flMsg" hidden style="font-size:13px;margin-bottom:10px"></div>' +
'<button id="flSubmit" style="width:100%;background:#2f9e63;border:none;color:#fff;padding:10px;border-radius:6px;font-size:14px;cursor:pointer">提交申请</button>' +
'</div>';
document.body.appendChild(mask);
mask.addEventListener('click', function (e) { if (e.target === mask) close(); }); mask.addEventListener('click', function (e) { if (e.target === mask) close(); });
document.getElementById('flApplyClose').addEventListener('click', close);
document.addEventListener('keydown', function (e) { if (e.key === 'Escape') close(); });
document.getElementById('flSubmit').addEventListener('click', function () { document.getElementById('flSubmit').addEventListener('click', function () {
var btn = this, msg = document.getElementById('flMsg'); var btn = this, msg = document.getElementById('flMsg');
@@ -103,6 +95,18 @@
btn.disabled = false; btn.textContent = '提交申请'; btn.disabled = false; btn.textContent = '提交申请';
}); });
}); });
return mask;
}
function close() {
var m = document.getElementById('flApplyMask');
if (m) m.setAttribute('hidden', '');
}
/* 供置顶评论卡片调用(artalk.js 的 comment-rendered 里触发) */
window.flApplyOpenModal = function () {
buildModal().removeAttribute('hidden');
};
})(); })();
</script> </script>
{{ end }} {{ end }}