Fix loadChapter: Support decimal chapters by using parseFloat comparison
This commit is contained in:
parent
223d05299f
commit
847d39ec54
@ -356,12 +356,13 @@ async function initReader() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadChapter(chapterId) {
|
async function loadChapter(chapterId) {
|
||||||
const chapter = chaptersData.find(c => c.id === chapterId);
|
// 支持小数章节,使用parseFloat比较
|
||||||
|
const chapter = chaptersData.find(c => parseFloat(c.id) === parseFloat(chapterId));
|
||||||
if (!chapter) {
|
if (!chapter) {
|
||||||
// 尝试从JSON文件直接加载
|
// 尝试从JSON文件直接加载
|
||||||
try {
|
try {
|
||||||
const chapterIdStr = chapterId.toString().padStart(2, '0');
|
const chapterIdStr = chapterId.toString();
|
||||||
const response = await fetch(`data/chapter-${chapterIdStr}.json`);
|
const response = await fetch(`data/chapter-${chapterIdStr}.json?v=${CACHE_VERSION}`);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
const normalizedData = normalizeChapterData(data, chapterId);
|
const normalizedData = normalizeChapterData(data, chapterId);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user