fix: reorder computed declarations in StoryGallery so chapterReachable is defined before use
This commit is contained in:
@@ -22,34 +22,6 @@ const emit = defineEmits<{
|
||||
|
||||
const showChapterPicker = ref(false)
|
||||
|
||||
function chaptersByProgress() {
|
||||
return [...props.chapters].sort((a, b) => {
|
||||
const pa = chapterProgress(a.id).pct
|
||||
const pb = chapterProgress(b.id).pct
|
||||
return pb - pa
|
||||
})
|
||||
}
|
||||
|
||||
const defaultChapter = computed(() => {
|
||||
const sorted = chaptersByProgress()
|
||||
for (const ch of sorted) {
|
||||
if (chapterProgress(ch.id).pct > 0) return ch
|
||||
}
|
||||
return sorted[0] ?? null
|
||||
})
|
||||
|
||||
const currentChapterId = ref<string>('')
|
||||
|
||||
if (defaultChapter.value) {
|
||||
currentChapterId.value = defaultChapter.value.id
|
||||
}
|
||||
|
||||
function selectChapter(chapterId: string) {
|
||||
if (!props.unlockedChapterIds.has(chapterId)) return
|
||||
currentChapterId.value = chapterId
|
||||
showChapterPicker.value = false
|
||||
}
|
||||
|
||||
function collectReachable(startId: string): Set<string> {
|
||||
const visited = new Set<string>()
|
||||
const queue = [startId]
|
||||
@@ -94,10 +66,6 @@ const chapterEndings = computed(() => {
|
||||
return result
|
||||
})
|
||||
|
||||
function endingStatus(endingId: string) {
|
||||
return props.visitedIds.has(props.endings.find(e => e.id === endingId)?.sceneId ?? '')
|
||||
}
|
||||
|
||||
function chapterProgress(chapterId: string) {
|
||||
const reachable = chapterReachable.value[chapterId]
|
||||
if (!reachable || reachable.size === 0) return { count: 0, total: 0, pct: 0 }
|
||||
@@ -128,6 +96,38 @@ function lockHint(sceneId: string): string {
|
||||
return ''
|
||||
}
|
||||
|
||||
function endingStatus(endingId: string) {
|
||||
return props.visitedIds.has(props.endings.find(e => e.id === endingId)?.sceneId ?? '')
|
||||
}
|
||||
|
||||
function chaptersByProgress() {
|
||||
return [...props.chapters].sort((a, b) => {
|
||||
const pa = chapterProgress(a.id).pct
|
||||
const pb = chapterProgress(b.id).pct
|
||||
return pb - pa
|
||||
})
|
||||
}
|
||||
|
||||
const defaultChapter = computed(() => {
|
||||
const sorted = chaptersByProgress()
|
||||
for (const ch of sorted) {
|
||||
if (chapterProgress(ch.id).pct > 0) return ch
|
||||
}
|
||||
return sorted[0] ?? null
|
||||
})
|
||||
|
||||
const currentChapterId = ref<string>('')
|
||||
|
||||
if (defaultChapter.value) {
|
||||
currentChapterId.value = defaultChapter.value.id
|
||||
}
|
||||
|
||||
function selectChapter(chapterId: string) {
|
||||
if (!props.unlockedChapterIds.has(chapterId)) return
|
||||
currentChapterId.value = chapterId
|
||||
showChapterPicker.value = false
|
||||
}
|
||||
|
||||
function buildPlayerTree(sceneId: string, depth: number, pathSet: Set<string>): PlayerTreeNode | null {
|
||||
if (depth > 10) return null
|
||||
if (pathSet.has(sceneId)) return null
|
||||
|
||||
Reference in New Issue
Block a user