fix(single): author card follow and identity parity

Add follow CTA to after-box author card, wrap bar label in span, and
harden follow.js label updates when span is missing.
This commit is contained in:
kate522 committed 2026-07-16 22:33:18 +08:00
1 parent 2c31da1454
commit 9b98080daf
3 files changed
+85 -57

No files matched your search

+14 -2
View File
@@ -68,16 +68,28 @@
function updateFollowButton(btn, isFollowing, count) {
var icon = btn.querySelector('i');
var text = btn.querySelector('span');
function setLabel(label) {
if (text) {
text.textContent = label;
return;
}
// Fallback when markup has bare text nodes next to the icon.
var nodes = Array.prototype.slice.call(btn.childNodes);
var textNode = nodes.filter(function (n) { return n.nodeType === 3 && n.textContent.trim() !== ''; })[0];
if (textNode) {
textNode.textContent = ' ' + label + ' ';
}
}
if (isFollowing) {
btn.classList.add('is-following');
if (icon) icon.className = 'fas fa-heart';
if (text) text.textContent = '已关注';
setLabel('已关注');
btn.title = '点击取消关注';
} else {
btn.classList.remove('is-following');
if (icon) icon.className = 'far fa-heart';
if (text) text.textContent = '关注';
setLabel('关注');
btn.title = '关注该用户';
}