🐛 修复目录倒序导致开书落到未购买章
ep_list 最新话在前,startIndex 默认取第一项于是开书总落在锁定章弹「本章未购买」。改为按 ord 升序排、加 toc_version 强制旧缓存重拉;首话 title 为空时回落 short_title。
This commit is contained in:
1 parent
5efe13834e
commit
93c0413424
2 files changed
+28
-9
No files matched your search
@@ -77,18 +77,29 @@ end
|
||||
-- Chapter 映射
|
||||
-- ============================================================
|
||||
|
||||
-- 目录缓存格式。ep_list 是倒序(最新话在前),版本 1 起按 ord 升序;旧缓存一律重拉。
|
||||
Mapper.TOC_VERSION = 1
|
||||
|
||||
function Mapper.chapters(comic)
|
||||
if not comic then return {} end
|
||||
local eps = comic.ep_list or {}
|
||||
local eps = {}
|
||||
for i, ep in ipairs(comic.ep_list or {}) do eps[i] = ep end
|
||||
table.sort(eps, function(a, b)
|
||||
if a.ord ~= b.ord then return (a.ord or 0) < (b.ord or 0) end
|
||||
return (a.id or 0) < (b.id or 0)
|
||||
end)
|
||||
local chapters = {}
|
||||
for i, ep in ipairs(eps) do
|
||||
local title = clean(ep.title):match("^%s*(.-)%s*$")
|
||||
if title == "" then title = clean(ep.short_title):match("^%s*(.-)%s*$") end
|
||||
chapters[#chapters + 1] = {
|
||||
idx = i,
|
||||
uid = tostring(ep.id),
|
||||
title = clean(ep.title or ep.short_title or ("第" .. i .. "话")),
|
||||
title = title ~= "" and title or ("第" .. i .. "话"),
|
||||
vip = ep.is_locked == true,
|
||||
}
|
||||
end
|
||||
if chapters[1] then chapters[1].toc_version = Mapper.TOC_VERSION end
|
||||
return chapters
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user