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
+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