From c628aac67f231d78ca45d56cea23abeb1837f7ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E6=97=A0=E6=95=8C=E6=95=B0=E7=A0=81?= =?UTF-8?q?=E6=9A=B4=E9=BE=99=E6=88=98=E5=A3=AB?= <1845519693@qq.com> Date: Wed, 25 Dec 2024 16:35:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E5=AF=BC=E8=88=AA=E6=A0=8F=E4=B8=8D=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/main/index.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/main/index.tsx b/src/pages/main/index.tsx index f386d4f..29d09f7 100644 --- a/src/pages/main/index.tsx +++ b/src/pages/main/index.tsx @@ -166,7 +166,11 @@ export default function Index() { ); })} </View> - <Swiper style={{ height: '70vh', width: '100vw' }} onChange={handleSwiperChange}> + <Swiper + style={{ height: '70vh', width: '100vw' }} + current={Object.keys(COURSE_NAME_MAP).indexOf(classType)} + onChange={handleSwiperChange} + > {Object.entries(scrollTopMap.current).map(([name]) => ( <SwiperItem key={name}> <ScrollView @@ -176,6 +180,8 @@ export default function Index() { onScrollToLower={loadMoreHandler} lowerThreshold={200} refresherEnabled + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + scrollTop={scrollTopMap.current[name]} style={{ height: '70vh' }} refresherTriggered={refresherTriggered} scrollY @@ -209,6 +215,7 @@ export default function Index() { onClick={() => { // 设置滚动条回到顶部 setScrollTop((prev) => (prev ? 0 : 1)); + scrollTopMap.current = { ...scrollTopMap.current, [classType]: 0 }; setTimeout(() => { setRefresherTriggered(true); void dispatch.refershComments().then(() => {