浏览代码

feat: 修改BUG

year 3 周之前
父节点
当前提交
d46d2c2a34

+ 0 - 0
public/user_heaer/h_1.png → public/user_header/h_1.png


+ 0 - 0
public/user_heaer/h_1.webp → public/user_header/h_1.webp


+ 0 - 0
public_original/user_heaer/h_1.png → public_original/user_header/h_1.png


+ 0 - 1
src/app/[locale]/(doings)/rank/detail/middle.tsx

@@ -24,7 +24,6 @@ const MiddleContainer: React.FC<Props> = ({ data, rankList = [], gamesInfo }) =>
         result[0] = res[1];
         result[1] = res[0];
         result[2] = res[2];
-        console.log(result);
         return result;
     }, [rankList]);
 

+ 9 - 6
src/app/[locale]/(doings)/rank/detail/page.tsx

@@ -28,7 +28,7 @@ const Page = () => {
     const [rankData, setRankData] = React.useState<RankItem[]>([]);
     const [areaId, setAreaId] = React.useState<number>(Number(searchParams.get("id")));
     const [loading, setLoading] = React.useState<boolean>(false);
-    const [initLoading, setInitLoading] = React.useState<boolean>(false);
+    const [initLoading, setInitLoading] = React.useState<boolean>(true);
     const [noMore, setNoMore] = React.useState<boolean>(false);
     const [modalType, setModalType] = React.useState<0 | -1>(0);
 
@@ -55,16 +55,17 @@ const Page = () => {
         setRankList([]);
         setData({} as any);
         getData();
+        // setInitLoading(true);
         // eslint-disable-next-line react-hooks/exhaustive-deps
     }, [areaId]);
 
     const getData = async () => {
         if (loading) return;
         try {
+            setLoading(true);
             if (pageInfo.current?.page === 1) {
                 setInitLoading(true);
             }
-            setLoading(true);
             const params: RankRequestParams = {
                 area_id: areaId,
                 type: 0,
@@ -100,10 +101,12 @@ const Page = () => {
     }, [data]);
 
     const swiperChange = (swiperData: RankItem) => {
-        router.replace(`/rank/detail?id=${swiperData.area_id}`);
-        setAreaId(swiperData.area_id);
-        pageInfo.current.page = 1;
-        getData();
+        if (swiperData.area_id !== areaId) {
+            router.replace(`/rank/detail?id=${swiperData.area_id}`);
+            setAreaId(swiperData.area_id);
+            pageInfo.current.page = 1;
+            getData();
+        }
     };
 
     const loadMore = () => {

+ 3 - 3
src/app/[locale]/(doings)/rank/detail/swiper.tsx

@@ -26,19 +26,19 @@ const RankSwiper: React.FC<Props> = ({ data = [], onChange, areaId }) => {
         }
     };
     React.useEffect(() => {
-        console.log(9999);
         setInnerData(data || []);
     }, [data]);
 
     React.useEffect(() => {
+        if (!innerData?.length) return;
         const idx = innerData.findIndex((item) => item.area_id === areaId);
-        if (idx !== -1) {
+        if (idx !== -1 && swiperRef.current?.activeIndex !== idx) {
             setTimeout(() => {
                 swiperRef.current?.slideTo(idx);
             }, 100);
         }
         // eslint-disable-next-line react-hooks/exhaustive-deps
-    }, [data, areaId]);
+    }, [innerData, areaId]);
 
     React.useEffect(() => {
         if (timer.current) {

+ 48 - 0
src/enums/index.tsx

@@ -105,4 +105,52 @@ export const HeaderImageMap = new Map<number, Record<string, any>>([
             img: "/user_header/h_1.webp",
         },
     ],
+    [
+        2,
+        {
+            img: "/user_header/h_1.webp",
+        },
+    ],
+    [
+        3,
+        {
+            img: "/user_header/h_1.webp",
+        },
+    ],
+    [
+        4,
+        {
+            img: "/user_header/h_1.webp",
+        },
+    ],
+    [
+        5,
+        {
+            img: "/user_header/h_1.webp",
+        },
+    ],
+    [
+        6,
+        {
+            img: "/user_header/h_1.webp",
+        },
+    ],
+    [
+        7,
+        {
+            img: "/user_header/h_1.webp",
+        },
+    ],
+    [
+        8,
+        {
+            img: "/user_header/h_1.webp",
+        },
+    ],
+    [
+        9,
+        {
+            img: "/user_header/h_1.webp",
+        },
+    ],
 ]);