v67:读书模块补齐(书能点进去 / 加一本 / 读书笔记 / 统计)

用户 2026-10-20:「其他的功能也逐步完成……读书点不进去,也没法加书,
设置也没有任何的东西。」

## 先修三处「对着服务端抄错的口径」(都不报错,只是显示是错的)
1. 状态值:服务端 `Book::STATUS` 只有 wish/reading/done/paused,**没有 want**;
   `Book::status()` 遇到不认识的值会静默改成 `wish`,而端上分组键写的 `want`
   ⇒ 书架里「想读」那一组**整组不显示**(页头还数着它,看着像书丢了)。
   `paused`(搁置)同样没列 ⇒ 搁置的书也人间蒸发。
2. 评分:服务端 `rating` 是 0–10,端上当 0–5 用 ⇒ 8 分显示成 `8.0/5`。
   现在解析时折半、写回时 ×2。
3. 进度:服务端 `progress` 是「读到第几章」,端上当百分比 ⇒ 读到第 30 章 = 30%。
   现在按 `chapter_count` 换算,没解析过章节的书不画假进度。

## 补齐三个死掉的入口
- 书行整行可点 → `FbBookSheet`(状态 / 评分 / 章节进度 / 读书笔记 / 删除二次确认)
- 页头「+ 加一本」→ 同一浮层的新建态(书名 / 作者 / 状态)
- 设置「读书统计」→ 端上现算(藏书/在读/读完/想读/搁置/笔记条数);
  另两条(导入笔记 / 微信读书)要文件选择与授权,仍标「网页端」,不摆假入口

## 服务端能力边界(照实做)
- `PATCH /books/<id>` 只认 status / rating ⇒ 详情里不给改书名/作者的输入框
- 章节进度只读(`progress` 由阅读器翻页写,接口没有回写入口)
- 读书笔记走真实接口 `GET/POST /books/<id>/notes`

## 验证
- `hvigorw assembleHap` → BUILD SUCCESSFUL
- `_fb_arkts_guard.js` → 797 / 0(新增 groupV67 28 条,含「端上分组键 ==
  服务端枚举」的跨语言对照)
- `_fb_v59d_falsify.py` → 130 / 0(v67 新增 13 条注入全部变红)
- ⚠️ 设备仍断连(`hdc list targets` → `[Empty]`),真机未验收
This commit is contained in:
2026-10-20 17:14:40 +08:00
parent 58f5509c1c
commit ec2cb14c4c
7 changed files with 1013 additions and 31 deletions
+21 -9
View File
@@ -298,13 +298,16 @@ export const FB_DEMO_RESOURCES: FbResourceItem[] = [
// 读书
// ============================================================
/* ⚠️ 状态用**服务端枚举**(`wish`),别写 `want` —— 见 `fbGroupBook` 上方的说明。
示例数据目前没有引用处(书架只吃接口/缓存),但它必须能编译、且不能把错的
取值示范给后来的人看。 */
export const FB_DEMO_BOOKS: FbBookItem[] = [
{ id: 1, title: '置身事内', author: '兰小欢', status: 'reading', rate: 5, noteCount: 12, progress: 62 },
{ id: 2, title: '地球的红飘带', author: '魏巍', status: 'reading', rate: 4, noteCount: 5, progress: 28 },
{ id: 3, title: '蛤蟆先生去看心理医生', author: '罗伯特·戴博德', status: 'done', rate: 5, noteCount: 9, progress: 100 },
{ id: 4, title: '一日三秋', author: '刘震云', status: 'done', rate: 4, noteCount: 7, progress: 100 },
{ id: 5, title: '显微镜下的大明', author: '马伯庸', status: 'done', rate: 5, noteCount: 15, progress: 100 },
{ id: 6, title: '也许你该找个人聊聊', author: '洛莉·戈特利布', status: 'want', rate: 0, noteCount: 0, progress: 0 }
{ id: 1, title: '置身事内', author: '兰小欢', status: 'reading', rate: 5, noteCount: 12, progress: 62, curChapter: 31, chapters: 50 },
{ id: 2, title: '地球的红飘带', author: '魏巍', status: 'reading', rate: 4, noteCount: 5, progress: 28, curChapter: 7, chapters: 25 },
{ id: 3, title: '蛤蟆先生去看心理医生', author: '罗伯特·戴博德', status: 'done', rate: 5, noteCount: 9, progress: 100, curChapter: 16, chapters: 16 },
{ id: 4, title: '一日三秋', author: '刘震云', status: 'done', rate: 4, noteCount: 7, progress: 100, curChapter: 24, chapters: 24 },
{ id: 5, title: '显微镜下的大明', author: '马伯庸', status: 'done', rate: 5, noteCount: 15, progress: 100, curChapter: 12, chapters: 12 },
{ id: 6, title: '也许你该找个人聊聊', author: '洛莉·戈特利布', status: 'wish', rate: 0, noteCount: 0, progress: 0, curChapter: 0, chapters: 0 }
];
// ============================================================
@@ -392,10 +395,19 @@ export function fbGroupResource(list: FbResourceItem[]): FbGroup<FbResourceItem>
return fbGroupBy(list, (it: FbResourceItem): string => it.ownerName);
}
/** 按 status 分组建书架(在读 / 想读 / 读完) */
/**
* 按 status 分组建书架(在读 / 想读 / 搁置 / 读完)
*
* 🔴🔴 v67:这四个键**必须**和服务端 `Book::STATUS` 一模一样
* (`wish / reading / done / paused`)。原来写的是 `want`:
* · 服务端不认 `want`,落库时被 `Book::status()` 静默改成 `wish`;
* · 这里又没列 `wish` ⇒ **"想读"的书在书架里整组消失**(页头还数着它)。
* `paused`(搁置)同理,原来也没列 ⇒ 搁置的书同样人间蒸发。
* ⚠️ 顺序按"手头正在看的排最前",与服务端 `ORDER BY FIELD(status, …)` 一致。
*/
export function fbGroupBook(list: FbBookItem[]): FbGroup<FbBookItem>[] {
const order: string[] = ['reading', 'want', 'done'];
const titles: string[] = ['在读', '想读', '读完'];
const order: string[] = ['reading', 'wish', 'paused', 'done'];
const titles: string[] = ['在读', '想读', '搁置', '读完'];
const groups: FbGroup<FbBookItem>[] = [];
for (let i = 0; i < order.length; i++) {
const key: string = order[i];
+13 -4
View File
@@ -34,11 +34,20 @@ export const FB_SET_MOVIES: FbSettingItem[] = [
{ icon: 'notes', label: '年度报告', hint: '这一年你看了些什么', action: 'moviereport' }
];
/** 读书(templates/books/_settings_menu.php) */
/**
* 读书(templates/books/_settings_menu.php)
*
* 🔴 v67(2026-10-20 用户「设置也没有任何的东西」):原来三条**全是空 `action`**
* ⇒ 整张菜单画成灰色、点哪条都没反应。
* · `bookstats` → 端上按书架现算(藏书/在读/读完/想读/搁置/笔记条数),**能进**;
* · 另两条要**文件选择**(导入读书笔记要读 .md/.txt)与**微信读书授权**,
* 移动端没有这条链路(`BookNoteImport` / `BookParser` 只被网页调用)
* ⇒ 仍然是「暂未开放」,但 hint 写明白"去网页端",别让人以为按钮坏了。
*/
export const FB_SET_BOOKS: FbSettingItem[] = [
{ icon: 'chart', label: '读书统计', hint: '每年读了多少、多少页', action: '' },
{ icon: 'plus', label: '导入读书笔记', hint: '从笔记文件批量导入', action: '' },
{ icon: 'share', label: '微信读书导入', hint: '同步微信读书的书单', action: '' }
{ icon: 'chart', label: '读书统计', hint: '藏书 / 在读 / 读完 / 笔记条数', action: 'bookstats' },
{ icon: 'plus', label: '导入读书笔记', hint: '要在网页端选文件', action: '' },
{ icon: 'share', label: '微信读书导入', hint: '要在网页端授权同步', action: '' }
];
/** 纪念日(templates/days/_settings_menu.php)
+37 -4
View File
@@ -756,19 +756,52 @@ export interface FbResourceItem {
// 读书(books)
// ============================================================
/** 一本书(books/index.php 书架) */
/**
* 一本书(books/index.php 书架)
*
* 🔴🔴 v67(2026-10-20)——把**三个和服务端口径不一致**的字段一次捋对,
* 这三个都是「不报错、不崩溃,但显示的东西是错的」:
*
* ① `status`:服务端 `Book::STATUS` 只有 `wish / reading / done / paused`,
* **没有 `want`**。而 `Book::status()` 遇到不认识的值会**静默改成 `wish`**,
* 端上分组又只认 `want` ⇒ 线上的"想读"的书在书架里**一本都不显示**
* (页头数字还数着它)—— 这正是"读书列表不对"的来源。
* ② `rate`:服务端 `rating` 是 **0–10**,端上一直当 0–5 用 ⇒ 8 分的书显示成 `8.0/5`。
* ③ `progress`:服务端 `progress` 是**读到第几章**(`Book::setProgress` 的注释写着
* 「读到第几章」),不是百分比 ⇒ 读到第 30 章的书,进度条永远停在 30%。
*/
export interface FbBookItem {
id: number;
title: string;
author: string;
/** 状态:want(想读)/ reading(在读)/ done(读完) */
/** 状态:`wish` 想读 / `reading` 在读 / `done` 读完 / `paused` 搁置(**必须以服务端枚举为准**) */
status: string;
/** 评分 0–5(0 表示未评) */
/** 评分 0–5(0 表示未评)。服务端存 0–10,解析时折半、写回时乘 2 */
rate: number;
/** 笔记条数 */
noteCount: number;
/** 阅读进度(0–100,done 时为 100) */
/** 阅读进度(0–100;读完恒 100,没解析过章节的书为 0) */
progress: number;
/** 读到第几章(服务端 `progress` 原值,0 = 还没开始) */
curChapter: number;
/** 共几章(服务端 `chapter_count`,0 = 这本书没解析过章节 ⇒ 进度无从谈起) */
chapters: number;
}
/** 一条读书笔记(`book_notes` 表:划线 / 想法 / 书评) */
export interface FbBookNoteItem {
id: number;
/** quote 划线 / note 想法 / review 书评 */
kind: string;
content: string;
/** 章节(导入时带得上的话) */
chapter: string;
/** 位置(页数 / 百分比 / 微信读书的定位串) */
loc: string;
/** 谁写的(显示名,可能为空 = 导入时不知道是谁) */
personName: string;
/** 记下的时间(只取日期) */
createdAt: string;
}
// ============================================================