feat(forum): frontend 1:1 list/tabs/urls/enqueue

Wire Zibll-style board sort tabs, shared topic rows, page-template
URLs, forum asset enqueue on home/plate, home synthesis load-more,
and topic last_reply meta for last-reply ordering. No dual-read.
This commit is contained in:
kate522 committed 2026-07-12 08:38:31 +08:00
1 parent df6b224dd3
commit 780c8cb4f7
23 files changed
+843 -481

No files matched your search

+201
View File
@@ -454,3 +454,204 @@
color: var(--color-primary);
}
/* Board sort tabs */
.aksrt-forum-board__tabs {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin: 0 0 16px;
padding: 8px;
border-radius: var(--radius-xl, 12px);
background: var(--surface-1, #fff);
box-shadow: var(--shadow-sm);
}
.aksrt-forum-board__tab {
display: inline-flex;
align-items: center;
padding: 8px 14px;
border-radius: 999px;
color: var(--color-ink-3, #5c6370);
text-decoration: none;
font-size: 14px;
font-weight: 600;
transition: background .15s ease, color .15s ease;
}
.aksrt-forum-board__tab:hover {
background: rgba(240, 68, 148, 0.08);
color: var(--color-primary, #f04494);
}
.aksrt-forum-board__tab.is-active {
background: var(--color-primary, #f04494);
color: #fff;
}
.aksrt-forum-board__governance--footer {
margin-top: 28px;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
gap: 16px;
}
.aksrt-forum-topic-row {
display: flex;
align-items: flex-start;
gap: 12px;
padding: 14px 16px;
margin-bottom: 10px;
border-radius: var(--radius-xl, 12px);
background: var(--surface-1, #fff);
box-shadow: var(--shadow-sm);
}
.aksrt-forum-topic-row__avatar img {
width: 40px;
height: 40px;
border-radius: 50%;
object-fit: cover;
}
.aksrt-forum-topic-row__body {
flex: 1;
min-width: 0;
}
.aksrt-forum-topic-row__title-wrap {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
}
.aksrt-forum-topic-row__title {
margin: 0;
font-size: 16px;
font-weight: 700;
}
.aksrt-forum-topic-row__title a {
color: var(--color-ink);
text-decoration: none;
}
.aksrt-forum-topic-row__meta {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-top: 6px;
color: var(--color-ink-4, #8a909c);
font-size: 12px;
}
.aksrt-forum-topic-row__badge {
display: inline-flex;
align-items: center;
padding: 2px 8px;
border-radius: 999px;
font-size: 12px;
font-weight: 700;
line-height: 1.4;
}
.aksrt-forum-topic-row__badge--sticky { background: rgba(255, 149, 0, 0.12); color: #c77700; }
.aksrt-forum-topic-row__badge--featured { background: rgba(240, 68, 148, 0.12); color: #f04494; }
.aksrt-forum-topic-row__badge--question { background: rgba(47, 128, 237, 0.12); color: #2f80ed; }
.aksrt-forum-topic-row__badge--question.is-solved { background: rgba(39, 174, 96, 0.12); color: #27ae60; }
.aksrt-forum-topic-row__cover {
position: relative;
width: 84px;
height: 60px;
flex: 0 0 auto;
border-radius: 10px;
overflow: hidden;
background: var(--surface-2, #f5f6f8);
}
.aksrt-forum-topic-row__cover img {
width: 100%;
height: 100%;
object-fit: cover;
}
.aksrt-forum-topic-row__cover .fa-play-circle,
.aksrt-forum-topic-row__cover-count {
position: absolute;
right: 6px;
bottom: 6px;
color: #fff;
text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.aksrt-forum-board-card__grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 12px;
}
.aksrt-forum-board-card {
display: flex;
flex-direction: column;
overflow: hidden;
border-radius: var(--radius-xl, 12px);
background: var(--surface-1, #fff);
box-shadow: var(--shadow-sm);
text-decoration: none;
color: inherit;
}
.aksrt-forum-board-card__cover {
display: block;
height: 96px;
background-size: cover;
background-position: center;
}
.aksrt-forum-board-card__cover--empty {
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, rgba(240,68,148,.08), rgba(47,128,237,.08));
color: var(--color-primary, #f04494);
font-size: 24px;
}
.aksrt-forum-board-card__body {
display: flex;
flex-direction: column;
gap: 6px;
padding: 12px 14px 14px;
}
.aksrt-forum-board-card__title {
font-weight: 700;
}
.aksrt-forum-board-card__desc,
.aksrt-forum-board-card__meta {
font-size: 12px;
color: var(--color-ink-4, #8a909c);
}
.aksrt-forum__empty,
.aksrt-forum-board__empty,
.aksrt-forum-tag__empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 10px;
padding: 48px 20px;
text-align: center;
color: var(--color-ink-4, #8a909c);
}
.aksrt-forum__empty a,
.aksrt-forum-board__empty a {
color: var(--color-primary, #f04494);
font-weight: 600;
text-decoration: none;
}
+56
View File
@@ -1322,6 +1322,61 @@
}
}
function bindBoardSortTabs() {
var root = document.querySelector('.aksrt-forum-board[data-plate-id], .aksrt-forum-board[data-board-id]');
if (!root) return;
var list = root.querySelector('.js-aksrt-board-topic-list');
var tabs = root.querySelectorAll('.js-aksrt-board-sort-tab');
if (!list || !tabs.length) return;
var plateId = root.getAttribute('data-plate-id') || '';
var boardId = root.getAttribute('data-board-id') || '';
var nonce = root.getAttribute('data-nonce') || (window.aksrtForumGovernance && aksrtForumGovernance.publicNonce) || (window.aksrtData && aksrtData.nonce) || '';
var ajaxUrl = (window.aksrtForumGovernance && aksrtForumGovernance.ajaxUrl) || (window.aksrtData && aksrtData.ajaxUrl) || '';
function loadSort(sort, pushUrl) {
if (!ajaxUrl) return;
list.style.opacity = '0.55';
var fd = new FormData();
fd.append('action', 'aksrt_forum_board_topics');
fd.append('nonce', nonce);
fd.append('page', '1');
fd.append('orderby', sort);
if (plateId) fd.append('plate_id', plateId);
if (boardId) fd.append('board_id', boardId);
fetch(ajaxUrl, { method: 'POST', body: fd, credentials: 'same-origin' })
.then(function (r) { return r.json(); })
.then(function (res) {
list.style.opacity = '1';
if (!res || !res.success) return;
list.innerHTML = res.data.html || '';
root.setAttribute('data-active-sort', sort);
tabs.forEach(function (t) {
t.classList.toggle('is-active', (t.getAttribute('data-sort') || '') === sort);
});
if (pushUrl && window.history && history.replaceState) {
try {
var u = new URL(window.location.href);
u.searchParams.set('forum_sort', sort);
history.replaceState({}, '', u.toString());
} catch (e) {}
}
})
.catch(function () { list.style.opacity = '1'; });
}
tabs.forEach(function (tab) {
tab.addEventListener('click', function (e) {
e.preventDefault();
var sort = tab.getAttribute('data-sort') || 'date';
if (sort === (root.getAttribute('data-active-sort') || '')) return;
loadSort(sort, true);
});
});
}
function boot() {
var composeForm = document.querySelector('.js-aksrt-forum-compose-form');
if (composeForm) {
@@ -1358,6 +1413,7 @@
document.querySelectorAll('.js-aksrt-unlock-topic').forEach(bindUnlockButton);
bindForumCommentEngine();
bindForumHomeTabs();
bindBoardSortTabs();
document.querySelectorAll('.js-aksrt-edit-plate').forEach(bindEditPlateButton);
document.querySelectorAll('.js-aksrt-delete-plate').forEach(bindDeletePlateButton);
var reportModal = document.querySelector('#aksrt-report-modal');