This commit is contained in:
大哥大哥的大哥哥
2026-09-09 14:47:29 +08:00
parent 4d9da40abd
commit 65755c9e96
832 changed files with 412085 additions and 0 deletions
@@ -0,0 +1,25 @@
const SHARED_GAME_CHAPTERS = new Set([1])
function normalizeChapterNumber(value) {
const number = Number(value)
if (!Number.isFinite(number)) return 1
return Math.min(15, Math.max(1, Math.floor(number)))
}
function chapterPackageRoot(value) {
const chapter = normalizeChapterNumber(value)
if (SHARED_GAME_CHAPTERS.has(chapter)) return 'package-game'
return `package-chapter-${String(chapter).padStart(2, '0')}`
}
function chapterRoute(value, options = {}) {
const chapter = normalizeChapterNumber(value)
const replay = options && options.replay === true ? '&replay=1' : ''
return `/${chapterPackageRoot(chapter)}/pages/chapter/chapter?chapter=${chapter}${replay}`
}
module.exports = {
normalizeChapterNumber,
chapterPackageRoot,
chapterRoute,
}