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
@@ -79,3 +79,11 @@
|
|||||||
3. 书架搜索支持书名/作者:/api/shelf 新增 keyword 参数(title LIKE OR author LIKE),原 category 改为精确匹配
|
3. 书架搜索支持书名/作者:/api/shelf 新增 keyword 参数(title LIKE OR author LIKE),原 category 改为精确匹配
|
||||||
4. 分类标签栏:书架页显示所有分类的可点击标签(pill 样式),点击筛选对应分类
|
4. 分类标签栏:书架页显示所有分类的可点击标签(pill 样式),点击筛选对应分类
|
||||||
5. 微信读书 CDN 封面前缀:t6_=低清(~150px), s_=超低清(~90px,搜索结果用), t8_=高清(~500px)
|
5. 微信读书 CDN 封面前缀:t6_=低清(~150px), s_=超低清(~90px,搜索结果用), t8_=高清(~500px)
|
||||||
|
|
||||||
|
## 12:27 移除分类排序按钮,默认按分类排序
|
||||||
|
|
||||||
|
- 用户反馈:分类排序不需要前端按钮,默认生效即可
|
||||||
|
- 删除 index.html 中的 shelfSortBtn 按钮
|
||||||
|
- app.js 中 shelfSortMode 默认值从 "default" 改为 "category"
|
||||||
|
- 删除 toggleShelfSort 函数和 .shelf-sort-btn CSS 样式
|
||||||
|
- 书架列表始终按分类分组渲染,无需手动切换
|
||||||
@@ -447,33 +447,6 @@ body {
|
|||||||
color: #fff;
|
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 区 ===== */
|
||||||
.hero-section {
|
.hero-section {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
+1
-25
@@ -690,14 +690,7 @@ async function loadShelf(page) {
|
|||||||
document.getElementById("shelfInfo").textContent =
|
document.getElementById("shelfInfo").textContent =
|
||||||
`共 ${data.total} 本 · 第 ${page}/${data.total_pages} 页`;
|
`共 ${data.total} 本 · 第 ${page}/${data.total_pages} 页`;
|
||||||
|
|
||||||
if (shelfSortMode === "category" && data.books.length > 0) {
|
grid.innerHTML = data.books.map((book) => renderBookCard(book)).join("");
|
||||||
// 按分类分组渲染
|
|
||||||
grid.innerHTML = renderBooksGroupedByCategory(data.books);
|
|
||||||
} else {
|
|
||||||
grid.innerHTML = data.books
|
|
||||||
.map((book) => renderBookCard(book))
|
|
||||||
.join("");
|
|
||||||
}
|
|
||||||
|
|
||||||
renderPagination(page, data.total_pages);
|
renderPagination(page, data.total_pages);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -722,23 +715,6 @@ function renderBookCard(book) {
|
|||||||
</div>`;
|
</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) {
|
function renderPagination(current, total) {
|
||||||
const pag = document.getElementById("pagination");
|
const pag = document.getElementById("pagination");
|
||||||
if (total <= 1) { pag.innerHTML = ""; return; }
|
if (total <= 1) { pag.innerHTML = ""; return; }
|
||||||
|
|||||||
Reference in new issue
Block a user