Repository navigation
阅读器重构优化:统一评论模型,数据全部改走宿主回调(TB-199) - #18
Merged
Merged
Conversation
- 划线、文字评论、整书评论、回复、赞踩和登录态全部经 annotation_callbacks 交给宿主, 阅读器不再直接请求 BRS 或账号接口;删除旧的评论面板、登录框、用户中心和 $backend 插件。 回调契约见 README。 - 新评论界面:评论抽屉(本章/本段)、完整评论页(本章/全书/我的)、评论详情页 (第一层回复不缩进、之后统一缩进一级)、赞踩互斥可取消、真删除、修改、 游客引导登录;桌面端改为覆盖式侧边栏。 - 跨段选区可写评论并归属最后一段;目录项共用一个正文文件时也能识别当前章节。 - iOS:左右翻页时页面固定不回弹;选中后轻点只取消选中不翻页;开启工具栏时关闭系统文字菜单、 工具栏优先放在选区下方;关闭工具栏时不再绘制自定义选区底色。 - 加载超过 60 秒才提示「加载较慢」且不中断加载,完成后自动关闭。 - 段尾评论气泡数字不再受书本首行缩进影响。 - 新增 demo.html(西游记 + 纯内存宿主 demo/memory-host.js)与介绍页 intro.html, make dist 生成 dist/demo.html 和 dist/index.html。 - e2e 改用内存宿主,全量 69 项通过。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- 设置只保留「显示全部划线和评论」「选中文字后显示工具栏」两个独立开关; 旧总开关关闭的读者迁移后两项都关闭,且不会再被旧值覆盖。 - 夜灰、纯黑主题下评论数层被刷成不透明底色盖住气泡轮廓,改为透明。 - 新增 DESIGN.md:架构、阅读器与宿主的职责边界、宿主回调规范、扩展指引。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- 新增 audiobook_callbacks(manifest / timeline 必选,start_session / report_progress / end_session 可选),由 src/audiobook.js 包装;播放器不再直接请求 /api/audiobooks 接口。 - 废弃 audiobook_edition_id、audiobook_manifest_url 选项。 - e2e harness 以宿主身份把回调翻译成 HTTP 请求;新增回调上下文用例,全量 68 项通过。 - DESIGN.md、README 同步有声书回调契约。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- list / replies 以 code 为 need_login 的错误拒绝时,评论区显示登录提示而不是错误,登录后自动重新加载。 - e2e harness 新增 &locked=1 模拟此类宿主;DESIGN.md 补充约定。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
气泡原为行内块,插入或移除时会让段落末行折行、后文下移,而 epub.js 的划线标记按绘制时的文字位置定位, 切换「显示全部划线和评论」后标记与原文错开。改为挂在零宽锚点上绝对定位,末行写满时向左收回页内。 新增回归用例(去掉修复会失败);全量 e2e 70 项通过。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
没有记录公开范围偏好、或读不到浏览器存储时,新建评论按私密处理。公开评论会经宿主同步到外部服务,不能在读者没有选择时默认外发;与 Talebook 划线笔记规格「默认私有」一致。读者选过公开后照旧记住该选择。 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g
- 段尾有 <br> 或换行空白时,零宽锚点会落到下一行,气泡跟着掉到下一行行首。 现在按段落最后一个可见字定位,与末行垂直居中、紧跟其后;末行写满时伸进右侧页边距。 字号、行距等设置或窗口尺寸变化后重新定位。 - 文字评论不再在正文铺底色,有评论的段落只用段尾气泡表示;划线底色不变。 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g
按 Rex 的产品决定撤回 e17129e:读者没有选过公开范围时,新评论默认公开;划线仍固定私密,读者选过私密后记住该选择。 This reverts commit e17129e. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g
主题只定制了背景色和面板色,强调色沿用 Vuetify 默认蓝;在护眼等主题下 「查看更多评论」、选中的范围页签、重试和已赞等文字与底色对比度仅 3.5:1。 改为把强调色与正文色按 6:4 混合,各主题实测 6.6:1 以上,并补 e2e 回归。 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g
一个正文文件里有多章时,一页可能从上一章末尾跨进下一章。此前段尾气泡和 正文标记只按页首章节读取,页尾那一章的段落写了评论也不显示气泡;点开 气泡时本段评论又按页首章节查询,列表为空。 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g
- 页首到页尾之间出现的每一章都读取段尾气泡和正文标记,不只首尾两章 - 一个正文文件里有多章时,目录按锚点区分当前章节,不再把同文件的各章都高亮 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g
目录、评论、设置在宽屏下的侧边栏内侧边缘显示胶囊形分隔条:拖动或用方向键、 Home / End 调整宽度,双击恢复默认;宽度按面板记住,范围 260px 到 min(720px, 窗口宽度 - 360px)。手机底部抽屉不显示。 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g
- 分隔条:9px 热区覆盖在面板边界上,1px 分隔线与边界重合,8×24 胶囊带握持刻度; 悬停、聚焦、拖动时变深蓝;方向键每次 16px,双击或 Home 恢复默认;面板去掉自身边框 - 评论列表里的私密记录在右下角显示「私密」 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g
Vuetify 给面板内容加了 0.2s 的 transition: all,宽度变化会追着指针慢半拍; 宽屏侧边栏只保留滑入滑出的 transform / opacity 过渡。 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
主题
阅读器重构优化。本 PR 是三个仓库联动改造中的阅读器部分:
背景
旧阅读器有两套互不相通的数据:
结果是两套界面、两套数据。Talebook 宿主页面还得拦截旧请求,自己另画一套选字工具栏和笔记侧栏。
这次重构确定了一条边界:阅读器只负责交互,不直接请求任何后端。评论、读者身份、权限和听书数据,全部通过宿主注入的回调获取。
关键改动
统一评论模型
$backend请求插件。新界面
宿主回调
annotation_callbacks:user / login / load / list / summary / get / replies / save / remove / vote。audiobook_callbacks:manifest / timeline / start_session / report_progress / end_session,有声书不再直接请求接口。DESIGN.md;README 给出接入示例。修复与体验
演示
make dev后打开/demo.html:《西游记》+纯内存宿主(demo/memory-host.js,完整实现回调契约),可体验全部功能。make dist生成可部署的dist/demo.html和介绍页dist/index.html。.github/workflows/pages.yml:合并进 main 后自动发布到 https://talebook.github.io/candle-reader/ (仓库 Settings → Pages 的 Source 需设为 GitHub Actions)。/candle-reader/、Talebook 的/static/candle-reader/)下也能加载。修复前在子路径下切到竹林皮肤,请求/themes/skins/zhulin-portrait.svg返回 404;修复后请求/candle-reader/themes/skins/zhulin-portrait.svg返回 200(本地用make dist产物挂在/candle-reader/下实测)。测试结果
npm run test:e2e:81 passed。e2e 用tests/e2e/fixtures/mock-host.js模拟宿主,覆盖:npm run build、npm run lint:通过。/login?next=…。未验证 / 已知限制
-webkit-touch-callout的支持)。兼容性
server、audiobook_edition_id、audiobook_manifest_url已废弃,传入会被忽略。宿主需改为注入回调(talebook#1079 已改)。annotation_callbacks时,评论存本机localStorage,公开范围不对他人生效。方案
talebook/talebook仓库的design/webserver/20261007-reader-unified-comments.active.html(ACTIVE):本 PR 早期轮次(统一划线笔记、主从设置、面板焦点恢复)对应 Talebook 方案
design/app/20260904-candle-reader-annotations.active.html。其中的总开关和直连 BRS 的章评、书评已被本次重构取代。🤖 Generated with Claude Code
https://claude.ai/code/session_01QTiGPhysXXAWy3buws8b7g