Skip to content

Commit

Permalink
fix: 修复首页点击导航栏不更新问题
Browse files Browse the repository at this point in the history
  • Loading branch information
konodioda727 committed Dec 25, 2024
1 parent b08a93f commit c628aac
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/pages/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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(() => {
Expand Down

0 comments on commit c628aac

Please sign in to comment.