书架页新增「最近在读」:构建时抓微信读书,顺带移除漫画/论文
数据链路 - scripts/fetch-reading.mjs:调腾讯官方 Agent Gateway (POST https://i.weread.qq.com/api/agent/gateway,Bearer wrk-...), /shelf/sync 拿书架,再对前 N 本调 /book/getprogress 拿进度, 写出 src/data/reading.json - src/lib/reading.ts:读 JSON + 按 YYYY-MM-DD 格式化(官方硬性要求), 文件缺失返回 null 让页面走空态而不是构建报错 - src/components/bookshelf-content.astro:只渲染,页面本身不发请求 接口实测得到的几个结论(都写进脚本注释和 README 了) - skill_version 必填,业务参数平铺顶层 - /shelf/sync 一次给全封面/书名/作者/分类/最近阅读时间/deepLink, 只有进度要额外请求,所以请求数 = 1 + N - progress 是 0-100 整数,只有 100 算读完 - recordReadingTime 恒为 0,所以卡片不做「累计时长」 - deepLink 实测是普通 https,浏览器能直接打开 失败兜底(这次最关键的一条) - pnpm reading:失败 exit 1,明确报错 - pnpm build:串的是 `fetch-reading.mjs --soft`,Key 失效/断网/接口挂了 都保留上一次的 reading.json 并 exit 0,不会阻塞部署 - 实测:错误 Key 时 pnpm reading exit 1;pnpm build 完整跑通 exit 0 且 reading.json 未被改动;不设 Key 也 exit 0 - process.loadEnvFile 不覆盖已存在的环境变量,所以 CI 设的 Key 优先于 .env Key 安全 - 只写进 .env(gitignore,权限 600),已确认 git status 里没有它 - deploy.sh 是本地构建再 rsync,凭据不会上传服务器 - .env.example 补了占位和申请地址 书架页改版 - 移除漫画/论文两个分类:删掉 tab 切换、两个视图、对应筛选和 JS, 956 行 -> 620 行;sidebar 的 tab 按钮改成 #reading / #books 页内锚点 - 新增「最近在读」区块置顶(Collection · 01),书籍顺延为 02 - 卡片:封面(hot-link 腾讯 CDN,referrerpolicy=no-referrer)+ 书名 + 作者 · 分类 + 进度条 + 最近阅读日期,整卡跳 weread.qq.com - 读完标「已读完」,0% 标「还没开始」 - 过滤私密阅读(secret=1)和从没打开过的书;有声书不处理 静态验证(dist/bookshelf/index.html) - 8 张在读卡片,链接均指向 weread.qq.com/book-detail - 8 条进度条宽度 30/0/77/100/28/13/97/0,与脚本输出一致 - 8 张封面全部 hot-link,无本地副本 - 漫画/论文/comics/papers/data-type-btn/switchType 均已从产物消失 - 其他页面(首页/时间线/关于/文章页)不含该区块,未受影响
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
{
|
||||
"updatedAt": "2026-09-15T02:39:58.551Z",
|
||||
"source": "weread",
|
||||
"books": [
|
||||
{
|
||||
"bookId": "26678299",
|
||||
"title": "大师和玛格丽特(果麦经典)",
|
||||
"author": "布尔加科夫",
|
||||
"category": "文学-外国文学",
|
||||
"cover": "https://wfqqreader-1252317822.image.myqcloud.com/cover/299/26678299/t6_26678299.jpg",
|
||||
"progress": 30,
|
||||
"finished": false,
|
||||
"lastReadAt": "2026-09-13T15:08:26.000Z",
|
||||
"deepLink": "https://weread.qq.com/book-detail?type=1&v=34c329807197141b34cf1db"
|
||||
},
|
||||
{
|
||||
"bookId": "3300048195",
|
||||
"title": "正面管教(修订版)",
|
||||
"author": "简•尼尔森",
|
||||
"category": "教育学习-育儿",
|
||||
"cover": "https://cdn.weread.qq.com/weread/cover/33/cpplatform_nxkyuocaxczycncqyfugye/t6_cpplatform_nxkyuocaxczycncqyfugye1675999568.jpg",
|
||||
"progress": 0,
|
||||
"finished": false,
|
||||
"lastReadAt": "2026-09-09T05:05:04.000Z",
|
||||
"deepLink": "https://weread.qq.com/book-detail?type=1&v=bbc32a50813ab7953g01522a"
|
||||
},
|
||||
{
|
||||
"bookId": "3300176703",
|
||||
"title": "关于建国以来党的若干历史问题的决议",
|
||||
"author": "中国共产党第十一届中央委员会",
|
||||
"category": "政治军事-政治",
|
||||
"cover": "https://cdn.weread.qq.com/weread/cover/6/cpplatform_bxvnmtl7wfftjdyxqgmpxt/t6_cpplatform_bxvnmtl7wfftjdyxqgmpxt1762827216.jpg",
|
||||
"progress": 77,
|
||||
"finished": false,
|
||||
"lastReadAt": "2026-09-07T09:27:28.000Z",
|
||||
"deepLink": "https://weread.qq.com/book-detail?type=1&v=de6321e0813abab86g01378d"
|
||||
},
|
||||
{
|
||||
"bookId": "3300020417",
|
||||
"title": "西线无战事(译文经典)",
|
||||
"author": "雷马克",
|
||||
"category": "文学-外国文学",
|
||||
"cover": "https://cdn.weread.qq.com/weread/cover/17/3300020417/t6_3300020417.jpg",
|
||||
"progress": 100,
|
||||
"finished": true,
|
||||
"lastReadAt": "2026-09-06T09:45:42.000Z",
|
||||
"deepLink": "https://weread.qq.com/book-detail?type=1&v=a1932750813ab6e79g017e78"
|
||||
},
|
||||
{
|
||||
"bookId": "23796324",
|
||||
"title": "昨日的世界",
|
||||
"author": "茨威格",
|
||||
"category": "文学-外国文学",
|
||||
"cover": "https://cdn.weread.qq.com/weread/cover/58/YueWen_23796324/t6_YueWen_23796324.jpg",
|
||||
"progress": 28,
|
||||
"finished": false,
|
||||
"lastReadAt": "2026-09-06T05:26:38.000Z",
|
||||
"deepLink": "https://weread.qq.com/book-detail?type=1&v=80a324f0716b1a6480af682"
|
||||
},
|
||||
{
|
||||
"bookId": "3300189057",
|
||||
"title": "我弥留之际(果麦经典)",
|
||||
"author": "[美]威廉·福克纳",
|
||||
"category": "精品小说-社会小说",
|
||||
"cover": "https://cdn.weread.qq.com/weread/cover/35/cpplatform_bypxixudgppfdrnvcvfuyq/t6_cpplatform_bypxixudgppfdrnvcvfuyq1766719527.jpg",
|
||||
"progress": 13,
|
||||
"finished": false,
|
||||
"lastReadAt": "2026-06-15T16:24:59.000Z",
|
||||
"deepLink": "https://weread.qq.com/book-detail?type=1&v=b4432330813abb059g01728a"
|
||||
},
|
||||
{
|
||||
"bookId": "23914527",
|
||||
"title": "树莓派开始,玩转Linux",
|
||||
"author": "Vamei 周昕梓",
|
||||
"category": "计算机-计算机综合",
|
||||
"cover": "https://cdn.weread.qq.com/weread/cover/55/YueWen_23914527/t6_YueWen_23914527.jpg",
|
||||
"progress": 97,
|
||||
"finished": false,
|
||||
"lastReadAt": "2026-06-10T16:14:02.000Z",
|
||||
"deepLink": "https://weread.qq.com/book-detail?type=1&v=140329d0716ce81f140468e"
|
||||
},
|
||||
{
|
||||
"bookId": "3300151878",
|
||||
"title": "从Python开始学编程",
|
||||
"author": "Vamei",
|
||||
"category": "计算机-计算机综合",
|
||||
"cover": "https://cdn.weread.qq.com/weread/cover/12/cpplatform_cmcqasqymymeqejem95ssq/t6_cpplatform_cmcqasqymymeqejem95ssq1751968250.jpg",
|
||||
"progress": 0,
|
||||
"finished": false,
|
||||
"lastReadAt": "2026-06-10T16:13:58.000Z",
|
||||
"deepLink": "https://weread.qq.com/book-detail?type=1&v=32f329e0813aba1d3g018fee"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user