修复粉丝/关注 TAB 的用户列表渲染

This commit is contained in:
kate522 committed 2026-08-23 14:12:42 +08:00
1 parent c6c2c0af6d
commit 84321801a6
7 files changed
+109 -72

No files matched your search

+1 -17
View File
@@ -15,6 +15,7 @@
})();
var NONCE = (window.aksrtData && window.aksrtData.restNonce) || '';
// 初始关注状态由服务端渲染(is-following class + 文案),无需逐按钮查询。
function initFollowButtons() {
document.addEventListener('click', function (e) {
var btn = e.target.closest('[data-aksrt-follow]');
@@ -50,23 +51,6 @@
btn.disabled = false;
});
});
// Check initial follow status for all follow buttons
document.querySelectorAll('[data-aksrt-follow]').forEach(function (btn) {
var targetUserId = parseInt(btn.getAttribute('data-aksrt-follow'));
if (!targetUserId) return;
fetch(API_ROOT + '/follow/status?target_user_id=' + targetUserId, {
headers: { 'X-WP-Nonce': NONCE },
})
.then(function (res) { return res.json(); })
.then(function (result) {
if (result.success && result.data) {
updateFollowButton(btn, result.data.is_following, result.data.follower_count);
}
})
.catch(function () { /* silent */ });
});
}
function updateFollowButton(btn, isFollowing, count) {