|
@@ -1,6 +1,6 @@
|
|
|
"use client";
|
|
|
import Box from "@/components/Box";
|
|
|
-import { FC, PropsWithChildren, ReactNode, useRef } from "react";
|
|
|
+import { FC, PropsWithChildren, ReactNode, useMemo, useRef } from "react";
|
|
|
|
|
|
import { Swiper, SwiperClass, SwiperSlide } from "swiper/react";
|
|
|
|
|
@@ -51,23 +51,58 @@ const HomeSwiper: FC<PropsWithChildren<SwiperGroupProps>> = (props) => {
|
|
|
"pt-[0.08rem]"
|
|
|
// "pb-[0.11rem]",
|
|
|
);
|
|
|
- if (!group.game_list) return;
|
|
|
- const lineNum = page * group.line_num;
|
|
|
-
|
|
|
- const gameList = group.game_list.slice(0, group.line_config_amount);
|
|
|
- const swiperData = Array(gameList.length ? Math.ceil(gameList.length / lineNum) : 0)
|
|
|
- .fill(0)
|
|
|
- .map((_, index) => {
|
|
|
- const showData = gameList
|
|
|
- .slice(index * lineNum, index * lineNum + lineNum)
|
|
|
- .map((subItem) => ({ ...subItem, category_name: group.category_name }));
|
|
|
-
|
|
|
- return {
|
|
|
- key: index,
|
|
|
- data: showData,
|
|
|
- };
|
|
|
- });
|
|
|
- console.log(swiperData);
|
|
|
+ const swiperData = useMemo(() => {
|
|
|
+ const max = page * group.line_num;
|
|
|
+ let gameList = group.game_list;
|
|
|
+ if (group.game_list.length >= max) {
|
|
|
+ gameList = group.game_list.slice(0, max - 1);
|
|
|
+ gameList.push({
|
|
|
+ isCustom: true,
|
|
|
+ category_name: group.category_name,
|
|
|
+ id: 0,
|
|
|
+ game_icon: "",
|
|
|
+ game_id: "",
|
|
|
+ game_name: "",
|
|
|
+ game_name_cn: "",
|
|
|
+ game_type: "",
|
|
|
+ provider: "",
|
|
|
+ release_date: "",
|
|
|
+ toDo: () => {
|
|
|
+ todoHandler && todoHandler(group);
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ index: 0,
|
|
|
+ key: group.category_name,
|
|
|
+ data: gameList,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }, [group, page]);
|
|
|
+ if (!swiperData?.length) return;
|
|
|
+
|
|
|
+ // const lineNum = page * group.line_num;
|
|
|
+
|
|
|
+ // const gameList = group.game_list.slice(0, group.line_config_amount);
|
|
|
+ // const swiperData = Array(gameList.length ? Math.ceil(gameList.length / lineNum) : 0)
|
|
|
+ // .fill(0)
|
|
|
+ // .map((_, index) => {
|
|
|
+ // const showData = gameList
|
|
|
+ // .slice(index * lineNum, index * lineNum + lineNum)
|
|
|
+ // .map((subItem) => ({ ...subItem, category_name: group.category_name }));
|
|
|
+ // console.log(150, 2 + index * page);
|
|
|
+ // if (index + 1 === group.line_num && group.game_list.length >= gameList.length) {
|
|
|
+ // showData.splice(2 + index * page, 1, { isCustom: true });
|
|
|
+ // }
|
|
|
+
|
|
|
+ // return {
|
|
|
+ // key: index,
|
|
|
+ // data: showData,
|
|
|
+ // };
|
|
|
+ // });
|
|
|
+ // console.log(150, swiperData);
|
|
|
const prev = () => {
|
|
|
swiperRef.current!.slidePrev();
|
|
|
};
|
|
@@ -104,10 +139,12 @@ const HomeSwiper: FC<PropsWithChildren<SwiperGroupProps>> = (props) => {
|
|
|
{visibleTodos && (
|
|
|
<div onClick={() => todoHandler && todoHandler(group)}>
|
|
|
{/* Todos */}
|
|
|
- <div className="text-[#d76bff]">Todo</div>
|
|
|
- <div className={styles.marginRightCount}>
|
|
|
- <span>{group.to_tal}</span>
|
|
|
+ <div className="bg-[#2b353f] px-[.02rem] py-[.02rem] text-[#788f97]">
|
|
|
+ todos
|
|
|
</div>
|
|
|
+ {/* <div className={styles.marginRightCount}>
|
|
|
+ <span>{group.to_tal}</span>
|
|
|
+ </div> */}
|
|
|
</div>
|
|
|
)}
|
|
|
|