修复空间Tab切换

This commit is contained in:
al 2025-02-11 19:28:29 +08:00
parent 556ef80e5e
commit 9192651354
1 changed files with 102 additions and 104 deletions

View File

@ -51,6 +51,7 @@ export default function Space() {
}, []);
useEffect(() => {
firstRequest();
setDataList([]);
}, [activeIndex]);
const firstRequest = () => {
resetOffset();
@ -65,7 +66,6 @@ export default function Space() {
};
const resetOffset = () => {
setOffset(0);
// setDataList([]);
};
const getSpaceList = async () => {
// setLoading(true);
@ -136,7 +136,7 @@ export default function Space() {
onChange={(key) => {
const index = tabItems.findIndex((item) => item.key === key);
setActiveIndex(index);
// swiperRef.current?.swipeTo(index);
swiperRef.current?.swipeTo(index);
}}
>
{tabItems.map((item) => (
@ -155,17 +155,18 @@ export default function Space() {
<OwnIcon src="/icons/search.png" className="w-9 h-9" />
</Link>
</div>
{}
<Swiper
direction="horizontal"
indicator={() => null}
// ref={swiperRef}
ref={swiperRef}
defaultIndex={activeIndex}
allowTouchMove={false}
onIndexChange={(index) => {
setActiveIndex(index);
}}
>
<Swiper.Item>
{!activeIndex && (
<div>
{!loading ? (
// <div className="px-4 pb-8">
@ -249,10 +250,8 @@ export default function Space() {
</div>
)}
</div>
)}
</Swiper.Item>
<Swiper.Item>
{!!activeIndex && (
<div className="px-4 pb-20">
<List className="scrollbarBox_hidden">
{loading && !dataList.length && (
@ -289,7 +288,6 @@ export default function Space() {
</div>
)} */}
</div>
)}
</Swiper.Item>
</Swiper>
<div