支持本地 TXT 小说上传#7
Open
Maple0517 wants to merge 5 commits into
Open
Conversation
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.
背景
当前项目主要通过远程书源搜索、加入书架、拉取目录和章节内容。对于用户本地已有的
.txt小说,原流程需要额外找书源或手动转换,使用成本比较高。这个 PR 增加“本地上传 TXT 小说”能力:用户可以直接在书架上传
.txt文件,后端解析章节并保存到当前用户的本地存储目录,前端把它当成普通书籍进入阅读器。主要改动
后端
LocalTxtBookService:.txt,最大 50MB。storage/data/<user>/local_books/<hash>/。/reader3/uploadTxtBook接口:/reader3/getBookInfo/reader3/getChapterList/reader3/getBookContent/reader3/saveBookProgress前端
isLocalTxtBook工具函数,统一判断本地 TXT 书籍。本次附带修复 / 加固
在 review 后补了几处关键加固:
local-txt:URL 后缀未校验的问题:local-txt:/absolute/path或local-txt:../path逃出local_books目录。local-txt:<hash>仍可读取。第一章初见第2章重逢navigator.onLine=false时仍会尝试请求后端读取本地文件:用户影响
.txt小说并加入书架。验证
已在干净 PR 分支
Maple/local-txt-upload-upstream上执行:cargo testcd frontend && npm test -- --runcd frontend && npm run build验证结果均通过。
说明:
cargo test期间仍会输出项目既有的 dead-code warning,本 PR 未新增这类 warning。