✨ feat(api): 新增榜单书架历史与搜索续传并重构正文缓存链路

- 新增 /rank 免签名榜单接口(多域名容错)、/bookshelf 与 /read-history(sessionid 登录态,书架支持分组过滤)
- 搜索重写:翻页透传上游 passback/search_id/next_offset/corrected_query 并按 book_id 去重,15~20 位纯数字关键词直查详情(ID 直搜)
- 删除 /login/check 登录校验端点(login.go、路由与文档同步移除,sessionid 说明改为直接供书架/历史使用)
- 正文链路重构:singleflight 合并同章节并发回源防击穿,缓存与解析解耦统一在出口处理,decodeContentBody 按 crypt_status 分支并兜底 500003 明文
- 缓存层:SQL 持久层 TTL 与业务 TTL 解耦(不可变内容过期后由 SQL 回填),动态短缓存只走 Redis,withCache 合并并发 miss
- 密钥池:KeyTs 随正文请求上传降低密钥不匹配重试,密钥超 24 小时异步刷新并防刷新风暴,last_used_at 批量落库
- 签名补 X-Helios(与 X-Ladon 同值,对齐书源实现);设备注册版本号统一走 ClientVersionCode/Name
- 分类 landing 透传新版标签 selected_items;multi-detail 批量详情供书架/历史复用
- README 与 openapi.yaml 补充新接口文档
This commit is contained in:
chenxin committed 2026-10-12 14:49:14 +08:00
1 parent 8ca372050b
commit 84bd3238ab
28 files changed
+1180 -270

No files matched your search

+19
View File
@@ -9,6 +9,20 @@ import (
"github.com/PuerkitoBio/goquery"
)
// imgSrcRe 匹配 img 标签的 src 属性
var imgSrcRe = regexp.MustCompile(`(?i)(<img[^>]*\ssrc=")([^"]*)(")`)
// permanentizeImgSrc 将正文插图链接替换为永久 CDN 链接(原链接带临时参数会过期)
func permanentizeImgSrc(html string) string {
return imgSrcRe.ReplaceAllStringFunc(html, func(m string) string {
parts := imgSrcRe.FindStringSubmatch(m)
if len(parts) < 3 || parts[2] == "" {
return m
}
return parts[1] + NormalizeNovelImageURL(parts[2]) + parts[3]
})
}
var (
parserLogger = common.NewLogger("content_parser", "INFO", "")
)
@@ -118,6 +132,8 @@ func (p *ContentParser) extractText(content string) string {
divHTML = decodeHTMLEntities(divHTML)
// 标准化img属性
divHTML = normalizeImgAttributes(divHTML)
// 插图链接永久化
divHTML = permanentizeImgSrc(divHTML)
finalResult = append(finalResult, divHTML)
}
return
@@ -173,6 +189,9 @@ func (p *ContentParser) processHTMLMode(content string) string {
// 解码HTML实体
content = decodeHTMLEntities(content)
// 插图链接永久化(原链接带临时参数会过期)
content = permanentizeImgSrc(content)
// 根据配置决定是否移除空行
if p.cfg.RemoveBlankLines {
// 对HTML内容移除空的<p>标签