- 新增 /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 补充新接口文档
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package fqapi
|
||
|
||
import (
|
||
"fanqie/internal/common"
|
||
"fmt"
|
||
)
|
||
|
||
var categoryFrontLogger = common.NewLogger("category_front", "INFO", "")
|
||
|
||
// HandleCategoryFront 处理获取分类列表,分类列表短缓存 10 分钟
|
||
func HandleCategoryFront(tab interface{}) (string, error) {
|
||
return withCache(fmt.Sprintf("category_front_%v", tab), 600, func() (string, error) {
|
||
return fetchCategoryFront(tab)
|
||
})
|
||
}
|
||
|
||
func fetchCategoryFront(tab interface{}) (string, error) {
|
||
tabInt := ParseIntParam(tab, 0)
|
||
|
||
// 新版分类接口参数(category_new_page_715=1 + new_category_type,
|
||
// 旧参数 new_category_tab 已失效——对齐 2026-10 可用的书源实现)
|
||
reqURL := BuildURL(
|
||
"https://reading.snssdk.com/reading/bookapi/new_category/front/v/",
|
||
"category_new_page_715=1",
|
||
fmt.Sprintf("new_category_type=%d", tabInt),
|
||
"update_version_code=" + ClientVersionCode,
|
||
"distinct_style=1",
|
||
)
|
||
|
||
resp, err := GorgonRequest(reqURL, map[string]interface{}{
|
||
"method": "GET",
|
||
"headers": map[string]string{
|
||
"User-Agent": "com.dragon.read",
|
||
},
|
||
})
|
||
|
||
if err != nil {
|
||
categoryFrontLogger.Error(fmt.Sprintf("获取分类列表失败: %v", err))
|
||
return BuildErrorResponse("请求失败"), err
|
||
}
|
||
|
||
respJSON, err := resp.JSON()
|
||
if err != nil {
|
||
return BuildErrorResponse("解析响应失败"), err
|
||
}
|
||
|
||
if code, ok := respJSON["code"].(float64); ok && code == 0 {
|
||
return reencodeUnwrapped(resp.Text), nil
|
||
}
|
||
|
||
return BuildErrorResponse("获取失败"), nil
|
||
}
|