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

This commit is contained in:
2026-10-04 19:11:27 +08:00
parent 00817766a6
commit 56bbb63afd
8 changed files with 261 additions and 131 deletions
+71 -92
View File
@@ -240,91 +240,82 @@
padding: 0;
display: flex;
flex-direction: column;
gap: 14px;
gap: 0;
}
.profile-comment-item {
position: relative;
padding: 16px 18px;
border: 1px solid var(--color-line);
border-radius: var(--radius-lg);
background: var(--surface-1);
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
transition: background-color var(--dur-fast) var(--ease),
border-color var(--dur-fast) var(--ease),
box-shadow var(--dur-fast) var(--ease);
}
.profile-comment-item::before {
content: none;
}
.profile-comment-item:hover {
background: var(--surface-1);
border-color: var(--color-line-strong, var(--color-line));
box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
}
.profile-comment-item__quote-link {
display: flex;
align-items: flex-start;
gap: 6px;
text-decoration: none;
color: var(--color-ink-2);
margin-bottom: 8px;
margin: 0;
padding: 20px 0;
border: 0;
border-radius: 0;
background: transparent;
box-shadow: none;
}
.profile-comment-item__quote-link:hover .profile-comment-item__quote-text {
color: var(--color-ink-2);
}
.profile-comment-item__quote-mark {
flex-shrink: 0;
font-family: var(--font-display);
font-size: 18px;
line-height: 1;
.profile-comment-item__time {
flex: 0 0 20%;
margin-right: 20px;
padding-top: 6px;
color: var(--color-ink-4);
opacity: 0.45;
margin-top: 2px;
text-align: right;
}
.profile-comment-item__quote-text {
flex: 1;
font-family: var(--font-body);
font-size: var(--text-sm, 0.875rem);
line-height: 1.65;
color: var(--color-ink-2);
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
.profile-comment-item__body {
flex: 0 1 calc(80% - 25px);
width: calc(80% - 25px);
min-width: 0;
overflow: hidden;
transition: color var(--dur-fast) var(--ease);
}
.profile-comment-item__meta {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
margin-left: 0;
font-size: 12px;
color: var(--color-ink-4);
.profile-comment-item__content-wrap {
margin-bottom: 10px;
}
.profile-comment-item__meta-item {
display: inline-flex;
align-items: center;
gap: 4px;
.profile-comment-item__content {
display: -webkit-box;
max-height: 7em;
overflow: hidden;
color: var(--color-ink-2);
line-height: 1.4em;
text-decoration: none;
white-space: normal;
-webkit-box-orient: vertical;
-webkit-line-clamp: 5;
}
.profile-comment-item__meta-item i {
font-size: 11px;
opacity: 0.75;
.profile-comment-item__content:hover {
color: var(--color-ink-2);
}
.profile-comment-item__meta-sep {
opacity: 0.5;
.profile-comment-item__pending {
margin-right: 6px;
}
.profile-comment-item__source {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.profile-comment-item__parent {
margin-right: 10px;
}
.profile-comment-item__post-link {
color: var(--color-ink-2);
font-weight: 500;
text-decoration: none;
transition: color var(--dur-fast) var(--ease);
}
.profile-comment-item__post-link:hover {
color: var(--color-ink);
.profile-comment-more {
margin: 20px 0;
text-align: center;
}
.profile-comment-more button {
padding: 5px 15px;
border: 0;
border-radius: 30px;
color: var(--color-ink-3);
background: transparent;
cursor: pointer;
opacity: .65;
}
.profile-comment-more button:hover {
background: var(--color-line);
opacity: 1;
}
.profile-comment-more button:disabled {
cursor: wait;
}
/* ==================== 分页 ==================== */
@@ -656,19 +647,15 @@
/* legacy-style user tabs: one panel outside, flat rows inside. */
.dashboard--public .profile-list,
.dashboard--public .profile-comment-list,
.uc-content #panel-posts .profile-list,
.uc-content #panel-favorites .profile-list,
.uc-content #panel-comments .profile-comment-list {
.uc-content #panel-favorites .profile-list {
gap: 0;
}
.dashboard--public .profile-list-item,
.dashboard--public .profile-comment-item,
.uc-content #panel-posts .profile-list-item,
.uc-content #panel-favorites .profile-list-item,
.uc-content #panel-favorites .profile-list[data-list="favorites"] .profile-list-item,
.uc-content #panel-comments .profile-comment-item {
.uc-content #panel-favorites .profile-list[data-list="favorites"] .profile-list-item {
padding: 16px 0;
background: transparent;
border: 0;
@@ -678,29 +665,23 @@
}
.dashboard--public .profile-list-item:hover,
.dashboard--public .profile-comment-item:hover,
.uc-content #panel-posts .profile-list-item:hover,
.uc-content #panel-favorites .profile-list-item:hover,
.uc-content #panel-favorites .profile-list[data-list="favorites"] .profile-list-item:hover,
.uc-content #panel-comments .profile-comment-item:hover {
.uc-content #panel-favorites .profile-list[data-list="favorites"] .profile-list-item:hover {
background: transparent;
border-color: var(--color-line-soft, rgba(0,0,0,0.06));
box-shadow: none;
}
.dashboard--public .profile-list-item:first-child,
.dashboard--public .profile-comment-item:first-child,
.uc-content #panel-posts .profile-list-item:first-child,
.uc-content #panel-favorites .profile-list-item:first-child,
.uc-content #panel-comments .profile-comment-item:first-child {
.uc-content #panel-favorites .profile-list-item:first-child {
padding-top: 0;
}
.dashboard--public .profile-list-item:last-child,
.dashboard--public .profile-comment-item:last-child,
.uc-content #panel-posts .profile-list-item:last-child,
.uc-content #panel-favorites .profile-list-item:last-child,
.uc-content #panel-comments .profile-comment-item:last-child {
.uc-content #panel-favorites .profile-list-item:last-child {
padding-bottom: 0;
border-bottom: 0;
}
@@ -779,26 +760,24 @@
@media (max-width: 640px) {
.dashboard--public .profile-list-item,
.dashboard--public .profile-comment-item,
.uc-content #panel-posts .profile-list-item,
.uc-content #panel-favorites .profile-list-item,
.uc-content #panel-comments .profile-comment-item {
.uc-content #panel-favorites .profile-list-item {
padding: 14px 0;
}
.dashboard--public .profile-list-item:first-child,
.dashboard--public .profile-comment-item:first-child,
.uc-content #panel-posts .profile-list-item:first-child,
.uc-content #panel-favorites .profile-list-item:first-child,
.uc-content #panel-comments .profile-comment-item:first-child {
.uc-content #panel-favorites .profile-list-item:first-child {
padding-top: 0;
}
.dashboard--public .profile-list-item:last-child,
.dashboard--public .profile-comment-item:last-child,
.uc-content #panel-posts .profile-list-item:last-child,
.uc-content #panel-favorites .profile-list-item:last-child,
.uc-content #panel-comments .profile-comment-item:last-child {
.uc-content #panel-favorites .profile-list-item:last-child {
padding-bottom: 0;
}
.profile-comment-item {
padding: 10px 0;
}
}
+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();