Commit Graph
20 Commits
Author SHA1 Message Date
admin 7d983e38da 书架恢复横向网格展示,移除分类分组标题
- loadShelf 始终用简单网格渲染,不再调用 renderBooksGroupedByCategory
- 删除 renderBooksGroupedByCategory 函数
- 清理 .shelf-group-header / .shelf-group-count CSS 样式
- 后端 sort=category 仍生效(按分类排序),前端不显示分组标题
- 分类筛选标签保留
2026-07-17 12:33:04 +08:00
admin 8b24052ab6 移除分类排序按钮,默认按分类排序展示
- 删除 index.html 中的 shelfSortBtn 按钮
- shelfSortMode 默认改为 category,始终按分类排序
- 删除 toggleShelfSort 函数和 .shelf-sort-btn CSS 样式
- 书架列表默认以分类分组渲染
2026-07-17 12:29:01 +08:00
admin e578a90543 feat: collapsible hierarchical category tags + category sort for shelf
- Backend: add parent_category param (matches '历史-*' sub-categories),
  sort=category mode (ORDER BY category ASC), return category_tree with
  parent→sub→count hierarchy
- Frontend: replace flat 63-tag list with collapsible parent tags showing
  book counts, click parent to expand sub-category pills with fade-in
  animation, click sub to filter to exact category
- Add '分类排序' toggle button: when active, books are grouped by
  category with colored section headers showing category name + count
- Clicking same parent again collapses it; '全部' resets everything
- Mobile responsive: smaller tag sizes, reduced indent on narrow screens
2026-07-17 12:21:36 +08:00
admin ec88707e6b fix: close thoughts page and modal when switching nav tabs
switchTab() now checks if the thoughts detail page or book detail modal
is open and closes them before switching to the target tab. Previously,
when on the thoughts page, clicking any nav tab (charts, ranking, etc.)
would silently fail because mainView was still hidden.
2026-07-17 12:17:10 +08:00
admin 90b9614b5e feat: add search and sort to thoughts detail page
- Search box: real-time filter across highlights, book reviews, and
  thoughts content (mark_text, content, abstract fields)
- Sort dropdown: 3 modes - newest first, oldest first, by chapter order
  (chapter_uid + range position)
- Chapter sort mode groups highlights by chapter with titles
- Time sort mode flattens highlights with chapter labels
- Empty state shows search keyword when no results match
- Mobile responsive: toolbar stacks vertically on narrow screens
2026-07-17 12:16:19 +08:00
admin d276608538 fix: replace weread:// deep link with web URL for 'Open in WeRead' button
The hardcoded 'weread://reading?bId=...' scheme only works on mobile
devices with the WeRead app installed. On desktop browsers, clicking
the button did nothing. Now uses data.deep_link from the API response
(https://weread.qq.com/...) with fallback logic: try weread:// scheme
via hidden iframe for 1.5s, then fall back to opening the web URL.
2026-07-17 12:14:12 +08:00
admin 4c916eceb7 feat: add global search bar, fix search cover blur, shelf title search + category tags
1. Fix hdCover() to also replace s_ prefix (search results use s_ not t6_)
2. Add persistent search bar below navbar, switches to discover tab on search
3. Shelf search now supports book title and author search (new keyword param)
4. Add category tag pills above book grid, click to filter by category
5. Update /api/shelf backend: keyword param for title/author, category for exact match
6. Mobile responsive styles for search bar and category tags
2026-07-17 12:12:23 +08:00
admin 7c918140b3 feat: add thoughts detail page, tab navigation, vertical ranking, back-to-top
1. Thoughts detail page: standalone full-page view replacing modal,
   classifies content into 3 categories (highlights/book reviews/thoughts)
   with filter tabs, visual badges, and chapter grouping
2. Tab navigation: sections converted from vertical scroll to horizontal
   tab switching with lazy-loaded charts
3. Reading ranking: changed from card grid to vertical list with smaller
   covers matching shelf size, gold/silver/bronze rank badges
4. Back-to-top button: floating button appears after scrolling 400px
5. Book detail modal: added 'View Thoughts' button to navigate to
   thoughts page
2026-07-17 11:30:24 +08:00
admin 4d8cc2a2d7 fix: clamp review star value to 0-5 range to prevent repeat() RangeError
WeRead API returns star=100 for book reviews and star=-1 for thoughts,
causing '☆'.repeat(5-100) to throw 'Invalid count value: -95'.
2026-07-17 11:17:55 +08:00
admin ae40ed93d6 feat: add dark/light theme toggle, fix cover display, refine overall style
- Add theme toggle button in navbar with sun/moon icons
- Define [data-theme=dark] CSS variables (warm dark palette)
- Persist theme preference in localStorage
- Follow system prefers-color-scheme on first visit
- Anti-flash inline script sets theme before render
- ECharts charts re-render with theme-aware colors on toggle
- Fix reading ranking covers: aspect-ratio 3/4 instead of fixed height
- Fix discover covers: aspect-ratio 3/4 for proper portrait display
- Replace purple hero gradient with warm brown/amber matching accent
- All hardcoded colors replaced with CSS variables
- Smooth 0.3s transitions on all theme-dependent elements
- Update footer text from SQLite to MySQL
2026-07-17 11:13:11 +08:00
admin 9c32f69f71 merge: data model v2.0 - 31 tables, complete API coverage, dual-column timestamps, audit columns, updated docs 2026-07-17 10:40:38 +08:00
admin 4c1a66ea6a docs: update technical and metadata docs for v2.0 (31 tables) 2026-07-17 10:40:33 +08:00
admin 2a809eb7cc refactor: complete data model v2.0 based on official API docs
数据模型全面重构,基于微信读书官方 8 份 API 文档逐字段比对:

1. 表结构从 18 张扩展到 31 张表:
   新增表:shelf_albums(有声书)、shelf_meta(书架元信息)、prefer_publishers(偏好出版社)、
   prefer_cps(偏好版权方)、prefer_books(偏好书籍卡片)、read_rank(好友排行)、
   medals(勋章)、year_reports(年度报告)、book_best_bookmarks(热门划线)、
   book_underlines(划线热度)、similar_books(相似推荐)、public_reviews(公开点评)、
   search_sessions(搜索会话)

2. 补全所有遗漏字段:
   - reading_stats: +13 个字段 (baseTime, compare, readRate, wrReadTime, wrListenTime 等)
   - book_chapters: +8 个字段 (wordCount, level, price, paid, isMPChapter, anchors 等)
   - book_reviews: +4 个字段 (abstract, range, chapterUid, chapterIdx)
   - recommended_books: +5 个字段 (deepLink, searchIdx, price, payType, type)
   - search_results: +8 个字段 (deepLink, payType, price, soldout, scope 等)
   - book_details: +2 个字段 (deepLink, newRatingDetail)
   - prefer_categories: +2 个字段 (parentCategoryId, categoryType)

3. 时间戳双列设计:
   - 所有整型时间戳字段均伴随 _dt TIMESTAMP 列 (如 read_update_time + read_update_time_dt)
   - 便于直接查询和展示,无需应用层转换

4. 审计字段:
   - 每张表均维护 created_at 和 updated_at
   - MySQL 使用 DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP

5. 索引优化:
   - 主键、唯一约束、查询索引根据实际访问模式重新设计
   - 新增复合索引、排序索引、全文检索索引

6. 数据采集脚本更新:
   - 覆盖所有新增表和字段的数据采集
   - skill_version 升级至 1.0.4
   - 有声书/专辑数据采集 (shelf_albums)
   - 偏好出版社/版权方/书籍卡片采集
   - 勋章、年度报告数据采集

7. 后端适配:
   - 移除旧版 ensure_tables 动态建表逻辑
   - 所有按需 API INSERT 语句适配新表结构
   - 搜索结果入库新增 search_sessions 会话表
   - 推荐书籍入库新增 batch_id 批次标识
2026-07-17 10:37:07 +08:00
admin 5e4de7a336 merge: merge dev into master - MySQL switch, Chinese comments, health check, docs 2026-07-17 10:26:14 +08:00
admin 507b9c5704 feat: switch to MySQL, add Chinese comments, health check, and technical docs
1. 数据源切换至 MySQL:
   - app.py 从 SQLite 切换到 PyMySQL,所有 API 读取 MySQL weread_dashboard 数据库
   - 新增 db_required 装饰器统一管理数据库连接和异常处理
   - 新增 /api/health 健康检查接口,检测 MySQL 连接状态
   - MySQL 连接失败时返回 HTTP 503 和告警信息
   - 修复 fetched_at 字段 Unix 时间戳到 MySQL TIMESTAMP 的兼容问题

2. 前端数据库连接告警:
   - 页面加载时优先调用 /api/health 检查 MySQL 连接
   - 连接失败时显示固定告警横幅,阻止后续数据加载
   - CSS 告警横幅样式(黄色背景、下滑动画)

3. 代码中文注释:
   - app.py:所有函数、API 接口、工具函数添加完整中文文档注释
   - fetch_data.py:所有 SQLite 建表语句添加列级中文注释
   - migrate_to_mysql.py:保留已有中文注释

4. 技术文档与元数据文档:
   - docs/TECHNICAL_DOC.md:项目概述、系统架构、API 设计、部署指南
   - docs/METADATA_DOC.md:18 张表完整字段说明、索引、表关系、数据类型规范
2026-07-17 10:26:07 +08:00
admin 292cb3f9e9 merge: merge dev into master - MySQL migration script 2026-07-17 10:16:47 +08:00
admin 72e9971a69 feat: add SQLite to MySQL migration script
- migrate_to_mysql.py:将 weread.db (SQLite) 全部 18 张表数据迁移至 MySQL weread_dashboard 数据库
- 支持时间戳列自动转换(SQLite int -> MySQL TIMESTAMP)
- 共迁移 862 行数据,中文内容 utf8mb4 完整保存
2026-07-17 10:16:41 +08:00
admin 463b736d13 merge: merge dev into master - book detail, notes, recommendation, MySQL schema
合并 dev 分支新功能到 master:
1. 书籍详情弹窗(点击书架书籍查看详情)
2. 笔记详情弹窗(点击笔记书籍查看划线和想法)
3. 推荐页面(个性化推荐 + 关键词搜索)
4. MySQL 版本建表语句
2026-07-17 10:07:11 +08:00
admin ebfa3a1852 feat: add book detail, notes detail, recommendation page and MySQL schema
新增功能:
- 书籍详情弹窗:点击书架书籍展示详细信息(书名、作者、出版社、ISBN、字数、评分、简介、阅读进度),数据实时从微信读书 API 获取并入库
- 笔记详情弹窗:点击有笔记的书展示划线和想法/点评,按章节分组展示,数据实时获取并入库
- 推荐页面:个性化推荐(为你推荐)+ 关键词搜索书籍,数据从微信读书 API 获取并入库
- 修复 Flask 中文 URL 参数编码问题

后端新增 API:
- GET /api/book/detail?book_id=xxx — 书籍详情
- GET /api/book/notes?book_id=xxx — 笔记详情(划线+想法)
- GET /api/recommend?maxIdx=0 — 个性化推荐
- GET /api/search?keyword=xxx — 搜索书籍

数据库新增表:
- book_details, book_progress, book_highlights, book_chapters
- book_reviews, recommended_books, search_results

MySQL 版本建表语句 schema_mysql.sql:
- 18 张表的完整 DDL,含索引、字符集 utf8mb4、字段注释
- 适用于后续从 SQLite 迁移至 MySQL
2026-07-17 10:07:05 +08:00
admin 1e9c537b86 feat: init weread data dashboard
- 数据采集脚本 fetch_data.py:从微信读书 API 拉取书架、阅读统计、笔记数据存入 SQLite
- Flask 后端 app.py:提供 8 个 API 接口(总览、年度趋势、读书排行、偏好分类、偏好作者、时段分布、书架、笔记)
- 前端页面:ECharts 图表(年度趋势、时段分布、分类饼图、作者排行)、书架网格、笔记概览
- 数据规模:404 本书架、339 小时阅读、304 天阅读、1709 条笔记
2026-07-17 09:59:37 +08:00