Conversation
Fixed-layout books (PDF/CBZ) always opened at the beginning: the open
flow called view.init({}) for fixed layout, deliberately(?) discarding
the lastLocation prop — so the saved position (books.current_cfi, e.g.
epubcfi(/6/16) for page 8) was never applied on open, while EPUB
restored fine through the sibling branch.
The fake page CFI (epubcfi(/6/N)) that the save side stores resolves
through the PDF backend's resolveCFI back to the recorded page, so
passing lastLocation to view.init restores the exact page. Verified
end-to-end on dev: read to page 5, close book, reopen -> page 5;
close app mid-read -> position flushed via beforeunload -> reopen ->
restored.
Also drops the temporary [RelocateDiag] probe logs.
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.
问题
PDF(及 CBZ 等固定版式)书籍每次打开都从第一页开始,不论上次读到哪里。EPUB 恢复正常。
根因
打开书籍的初始化流程中,固定版式分支被硬编码丢弃了上次阅读位置:
保存侧完全正常(books.current_cfi 正确存储页级定位 epubcfi(/6/N)),只是打开时未使用。
修复
固定版式分支同样将 lastLocation 传入 view.init。PDF 的页级 fake CFI(epubcfi(/6/N))可通过 PDF 后端的 resolveCFI 解析回对应页,与注释/书签跳转使用同一套已验证机制。
验证
注:本次代码修改和PR信息由AI生成