From 7d983e38da35b704e1756788ee73c162a3ce3f25 Mon Sep 17 00:00:00 2001 From: kinghwj Date: Fri, 17 Jul 2026 12:33:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=A6=E6=9E=B6=E6=81=A2=E5=A4=8D=E6=A8=AA?= =?UTF-8?q?=E5=90=91=E7=BD=91=E6=A0=BC=E5=B1=95=E7=A4=BA=EF=BC=8C=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=88=86=E7=B1=BB=E5=88=86=E7=BB=84=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - loadShelf 始终用简单网格渲染,不再调用 renderBooksGroupedByCategory - 删除 renderBooksGroupedByCategory 函数 - 清理 .shelf-group-header / .shelf-group-count CSS 样式 - 后端 sort=category 仍生效(按分类排序),前端不显示分组标题 - 分类筛选标签保留 --- .workbuddy/memory/2026-07-17.md | 8 ++++++++ static/css/style.css | 27 --------------------------- static/js/app.js | 26 +------------------------- 3 files changed, 9 insertions(+), 52 deletions(-) diff --git a/.workbuddy/memory/2026-07-17.md b/.workbuddy/memory/2026-07-17.md index 0973cf4..bb3a906 100644 --- a/.workbuddy/memory/2026-07-17.md +++ b/.workbuddy/memory/2026-07-17.md @@ -79,3 +79,11 @@ 3. 书架搜索支持书名/作者:/api/shelf 新增 keyword 参数(title LIKE OR author LIKE),原 category 改为精确匹配 4. 分类标签栏:书架页显示所有分类的可点击标签(pill 样式),点击筛选对应分类 5. 微信读书 CDN 封面前缀:t6_=低清(~150px), s_=超低清(~90px,搜索结果用), t8_=高清(~500px) + +## 12:27 移除分类排序按钮,默认按分类排序 + +- 用户反馈:分类排序不需要前端按钮,默认生效即可 +- 删除 index.html 中的 shelfSortBtn 按钮 +- app.js 中 shelfSortMode 默认值从 "default" 改为 "category" +- 删除 toggleShelfSort 函数和 .shelf-sort-btn CSS 样式 +- 书架列表始终按分类分组渲染,无需手动切换 diff --git a/static/css/style.css b/static/css/style.css index fa2d626..cfe6e7e 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -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; diff --git a/static/js/app.js b/static/js/app.js index 99fcef9..ecf0053 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -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) { `; } -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 += `
${cat} ${items.length} 本
`; - html += `
${items.map(renderBookCard).join("")}
`; - } - return html; -} - function renderPagination(current, total) { const pag = document.getElementById("pagination"); if (total <= 1) { pag.innerHTML = ""; return; }