mirror of
https://github.com/KingHWJ/WeReadBoard.git
synced 2026-11-03 18:24:58 +08:00
书架恢复横向网格展示,移除分类分组标题
- loadShelf 始终用简单网格渲染,不再调用 renderBooksGroupedByCategory - 删除 renderBooksGroupedByCategory 函数 - 清理 .shelf-group-header / .shelf-group-count CSS 样式 - 后端 sort=category 仍生效(按分类排序),前端不显示分组标题 - 分类筛选标签保留
This commit is contained in:
1 parent
8b24052ab6
commit
7d983e38da
3 files changed
+9
-52
No files matched your search
@@ -447,33 +447,6 @@ body {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* 分类分组标题 */
|
||||
.shelf-group-header {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
margin: 24px 0 12px;
|
||||
padding: 8px 16px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--accent-bg);
|
||||
border-left: 4px solid var(--accent);
|
||||
}
|
||||
|
||||
.shelf-group-header:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.shelf-group-count {
|
||||
font-size: 12px;
|
||||
font-weight: 400;
|
||||
color: var(--text-light);
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.shelf-group-header + .book-grid {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
/* ===== Hero 区 ===== */
|
||||
.hero-section {
|
||||
position: relative;
|
||||
|
||||
+1
-25
@@ -690,14 +690,7 @@ async function loadShelf(page) {
|
||||
document.getElementById("shelfInfo").textContent =
|
||||
`共 ${data.total} 本 · 第 ${page}/${data.total_pages} 页`;
|
||||
|
||||
if (shelfSortMode === "category" && data.books.length > 0) {
|
||||
// 按分类分组渲染
|
||||
grid.innerHTML = renderBooksGroupedByCategory(data.books);
|
||||
} else {
|
||||
grid.innerHTML = data.books
|
||||
.map((book) => renderBookCard(book))
|
||||
.join("");
|
||||
}
|
||||
grid.innerHTML = data.books.map((book) => renderBookCard(book)).join("");
|
||||
|
||||
renderPagination(page, data.total_pages);
|
||||
} catch (e) {
|
||||
@@ -722,23 +715,6 @@ function renderBookCard(book) {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function renderBooksGroupedByCategory(books) {
|
||||
// 按 category 分组
|
||||
const groups = {};
|
||||
books.forEach((book) => {
|
||||
const cat = book.category || "未分类";
|
||||
if (!groups[cat]) groups[cat] = [];
|
||||
groups[cat].push(book);
|
||||
});
|
||||
|
||||
let html = "";
|
||||
for (const [cat, items] of Object.entries(groups)) {
|
||||
html += `<div class="shelf-group-header">${cat} <span class="shelf-group-count">${items.length} 本</span></div>`;
|
||||
html += `<div class="book-grid">${items.map(renderBookCard).join("")}</div>`;
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
function renderPagination(current, total) {
|
||||
const pag = document.getElementById("pagination");
|
||||
if (total <= 1) { pag.innerHTML = ""; return; }
|
||||
|
||||
Reference in new issue
Block a user