fix(user-home): align profile comments with reference theme

This commit is contained in:
kate522 committed 2026-10-04 19:11:27 +08:00
1 parent 00817766a6
commit 56bbb63afd
8 files changed
+261 -131

No files matched your search

+46 -2
View File
@@ -60,7 +60,25 @@
});
}
function loadPanelBody(panel, name, page, sub) {
function appendCommentPage(panel, html) {
var fragment = document.createElement('div');
fragment.innerHTML = html;
var currentList = panel.querySelector('.profile-comment-list');
var incomingList = fragment.querySelector('.profile-comment-list');
if (currentList && incomingList) {
Array.prototype.slice.call(incomingList.children).forEach(function (item) {
currentList.appendChild(item);
});
}
var currentMore = panel.querySelector('.profile-comment-more');
var incomingMore = fragment.querySelector('.profile-comment-more');
if (currentMore) currentMore.remove();
if (incomingMore && currentList) currentList.insertAdjacentElement('afterend', incomingMore);
}
function loadPanelBody(panel, name, page, sub, appendComments, trigger) {
var cfg = window.aksrtData || {};
var restBase = cfg.apiUrl || cfg.restUrl || '';
if (!userId || !restBase) return Promise.reject(new Error('rest-unavailable'));
@@ -74,6 +92,11 @@
panel.dataset.uhPage = String(page);
panel.dataset.uhSub = followSub;
}
if (appendComments && trigger) {
trigger.disabled = true;
trigger.setAttribute('aria-busy', 'true');
trigger.textContent = '加载中…';
}
panel.classList.add('is-loading');
var url = restBase.replace(/\/$/, '') + '/user-home/panel/' + userId + '/' + encodeURIComponent(name)
@@ -89,10 +112,21 @@
if (!response.ok || !payload || !payload.success || !payload.data || typeof payload.data.html !== 'string') {
throw new Error('panel-load-failed');
}
panel.innerHTML = payload.data.html;
if (appendComments && name === 'comments') {
appendCommentPage(panel, payload.data.html);
} else {
panel.innerHTML = payload.data.html;
}
if (window.jQuery) jQuery(document).trigger('post_ajax.ed', [panel]);
if (typeof window.auto_fun === 'function') window.auto_fun();
});
}).catch(function (error) {
if (appendComments && trigger && trigger.isConnected) {
trigger.disabled = false;
trigger.removeAttribute('aria-busy');
trigger.textContent = '加载更多';
}
throw error;
}).finally(function () {
panel._aksrtUhRequest = null;
panel.classList.remove('is-loading');
@@ -127,6 +161,16 @@
return;
}
var commentsNext = target.closest('[data-uh-comments-next]');
if (commentsNext) {
event.preventDefault();
var commentsPanel = commentsNext.closest('.dashboard-panel');
if (!commentsPanel) return;
var commentsPage = Math.max(2, parseInt(commentsNext.getAttribute('data-uh-comments-next') || '2', 10) || 2);
loadPanelBody(commentsPanel, 'comments', commentsPage, 'followers', true, commentsNext).catch(notifyLoadError);
return;
}
var pageBtn = target.closest('[data-uh-page]');
if (!pageBtn) return;
event.preventDefault();