mirror of
https://github.com/truewhile/MeBox.git
synced 2026-11-16 20:54:23 +08:00
feat(reader): P2 收尾——冒烟 CLI、书架正文链路、替换净化规则
- SmokeChain 结构化全链路冒烟(搜索→详情→目录→正文,分阶段失败定位), SmokeSource 支持不落库直测;Debug 接口改为结构化日志输出 - cmd/reader-smoke:批量书源冒烟 CLI(-file/-url 导入、并发、 各阶段通过率汇总、-json 完整报告) - GetContentForBook:书架维度正文(章节缓存 + 书源 replaceRegex + 用户替换净化规则),前端阅读器切换到该接口 - 替换净化规则 CRUD(后端 + /reader/replace 前端页),用户规则 按 scope/excludeScope 书名过滤、正则带匹配超时防回溯挂死 - rule.ApplyUserReplace 导出(regexp2 MatchTimeout)
This commit is contained in:
@@ -112,14 +112,11 @@ export default function ReaderViewPage() {
|
||||
setContent(null)
|
||||
setLoadingStage('content')
|
||||
try {
|
||||
let ct = contentCache.current.get(ch.url)
|
||||
const cacheKey = String(chapterIndex)
|
||||
let ct = contentCache.current.get(cacheKey)
|
||||
if (!ct) {
|
||||
ct = await readerAPI.content({
|
||||
source_url: book.origin,
|
||||
book_url: book.book_url,
|
||||
chapter_url: ch.url,
|
||||
})
|
||||
contentCache.current.set(ch.url, ct)
|
||||
ct = await readerAPI.bookContent(book.id, chapterIndex)
|
||||
contentCache.current.set(cacheKey, ct)
|
||||
}
|
||||
if (cancelled) return
|
||||
setContentType(ct.type)
|
||||
@@ -131,11 +128,10 @@ export default function ReaderViewPage() {
|
||||
.saveProgress(book.id, { chapter_index: chapterIndex, pos: pendingPosRef.current, chapter_title: ch.title })
|
||||
.catch(() => undefined)
|
||||
// 预取下一章
|
||||
const next = chapters[chapterIndex + 1]
|
||||
if (next && !contentCache.current.has(next.url)) {
|
||||
if (!contentCache.current.has(String(chapterIndex + 1))) {
|
||||
readerAPI
|
||||
.content({ source_url: book.origin, book_url: book.book_url, chapter_url: next.url })
|
||||
.then((c) => contentCache.current.set(next.url, c))
|
||||
.bookContent(book.id, chapterIndex + 1)
|
||||
.then((c) => contentCache.current.set(String(chapterIndex + 1), c))
|
||||
.catch(() => undefined)
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -359,8 +355,7 @@ export default function ReaderViewPage() {
|
||||
onClick={() => {
|
||||
setError('')
|
||||
if (chapterIndex !== null) {
|
||||
const ch = chapters[chapterIndex]
|
||||
if (ch) contentCache.current.delete(ch.url)
|
||||
contentCache.current.delete(String(chapterIndex))
|
||||
setChapterIndex(chapterIndex)
|
||||
}
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user