22import { SharedFunction } from ' @delta-comic/core'
33import { uni } from ' @delta-comic/model'
44import { useConfig } from ' @delta-comic/plugin'
5- import { shallowRef , useTemplateRef } from ' vue'
5+ import { useInfiniteQuery } from ' @pinia/colada'
6+ import { computed , nextTick , shallowRef , useTemplateRef } from ' vue'
67import { useRoute } from ' vue-router'
78
89import * as LayoutInject from ' ../default'
@@ -25,27 +26,25 @@ const routeToContent = (preload: uni.item.RawItem) =>
2526
2627const config = useConfig ()
2728
28- const queryEps = useInfQuery ({
29+ const queryEps = useInfiniteQuery ({
2930 key : () => [LayoutInject .QueryKey .Ep , LayoutInject .createPageQueryKey ($props .page )],
30- query : () => $props .page
31+ query : async ({ signal , pageParam }) => await $props .page .fetchEps (pageParam , signal ),
32+ initialPageParam: $props .page .fetchEps .initialPageParam ,
33+ getNextPageParam : lp => lp .nextPage
3134})
35+ const eps = computed (() => queryEps .data .value ?.pages .flat () ?? [])
3236
3337const epSelList = useTemplateRef (' epSelList' )
3438const isShowEpSelectPopup = shallowRef (false )
35- const eps = computedAsync (
36- async () => sortBy (await $props .page .eps .content , v => Number (v .index )),
37- []
38- )
3939
4040const nowEpId = $route .params .ep .toString ()
41- const nowEp = computed (() => eps .value .find (ep => ep .index === nowEpId ))
42- const nowEpIndex = computed (() => eps .value .findIndex (ep => ep .index === nowEpId ))
41+ const nowEp = computed (() => eps .value .find (ep => ep .id === nowEpId ))
42+ const nowEpIndex = computed (() => eps .value .findIndex (ep => ep .id === nowEpId ))
4343const openEpSelectPopup = async () => {
44- scrollbar .value ?.scrollTo (0 , 0 )
4544 isShowEpSelectPopup .value = true
4645 await nextTick ()
4746 epSelList .value ?.listInstance ?.scrollTo ({
48- index: eps .value .findIndex (ep => ep .index === nowEpId )
47+ index: eps .value .findIndex (ep => ep .id === nowEpId )
4948 })
5049}
5150 </script >
@@ -84,16 +83,17 @@ const openEpSelectPopup = async () => {
8483 <div class =" flex h-10 w-full items-center pt-2 pl-8 text-lg font-bold" >选集</div >
8584 <DcList
8685 class="h-full w-full"
87- :source =" { data: PromiseContent . resolve ( eps ), isEnd: true } "
86+ :source =" { type: ' infinite ' , value: queryEps } "
8887 :itemHeight =" 40 "
8988 v-slot =" { data: { item: ep , index }, height } "
9089 ref="epSelList"
9190 >
9291 <VanCell
92+ v-if =" union "
9393 clickable
9494 @click =" routeToContent ({ ... union .toJSON (), thisEp: ep .toJSON () })"
9595 :title =" ep .name || ` 第${index + 1 }话 ` "
96- :title-class =" [nowEpId === ep .index && ' font-bold text-(--p-color)!' ] "
96+ :title-class =" [nowEpId === ep .id && ' font-bold text-(--p-color)!' ] "
9797 class="flex w-full items-center"
9898 :style =" { height: ` ${height }px !important ` } "
9999 >
0 commit comments