|
@@ -3,13 +3,14 @@ import { gamesNoticeWinApi, GameListRep } from "@/api/home";
|
|
|
import Box from "@/components/Box";
|
|
|
import { Button, Popup } from "antd-mobile";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
-import { FC, useEffect, useState } from "react";
|
|
|
+import { FC, useState } from "react";
|
|
|
import { Autoplay } from "swiper/modules";
|
|
|
import { Swiper, SwiperSlide } from "swiper/react";
|
|
|
import { useRouter } from "@/i18n/routing";
|
|
|
import { getToken } from "@/utils/Cookies";
|
|
|
import { useWalletStore } from "@/stores/useWalletStore";
|
|
|
import useGame from "@/hooks/useGame";
|
|
|
+import { useRequest } from "ahooks";
|
|
|
import styles from "@/components/Card/style.module.scss";
|
|
|
|
|
|
interface Props {}
|
|
@@ -18,16 +19,17 @@ const HomePrize: FC<Props> = () => {
|
|
|
const t = useTranslations("HomePage");
|
|
|
const tt = useTranslations("Game");
|
|
|
|
|
|
- const [winImg, setWinImg] = useState<any>([]);
|
|
|
- const gamesNoticeWinRequest = async () => {
|
|
|
- gamesNoticeWinApi()
|
|
|
- .then((res: any) => {
|
|
|
- if (res.code === 200) setWinImg(res.data || []);
|
|
|
- })
|
|
|
- };
|
|
|
- useEffect(() => {
|
|
|
- gamesNoticeWinRequest()
|
|
|
- }, [])
|
|
|
+ const [winImg, setWinImg] = useState<any>([{}]);
|
|
|
+ const { run, cancel } = useRequest(gamesNoticeWinApi, {
|
|
|
+ pollingInterval: 600000,
|
|
|
+ pollingWhenHidden: true,
|
|
|
+ pollingErrorRetryCount: 3,
|
|
|
+ staleTime: 5000,
|
|
|
+ onError: (error) => {},
|
|
|
+ onSuccess: (res) => {
|
|
|
+ setWinImg(res.data || []);
|
|
|
+ },
|
|
|
+ });
|
|
|
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
const [gameInfo, setGameInfo] = useState<any>({});
|
|
@@ -73,7 +75,7 @@ const HomePrize: FC<Props> = () => {
|
|
|
autoplay={{
|
|
|
delay: 3000,
|
|
|
}}
|
|
|
- modules={[Autoplay]}
|
|
|
+ modules={[Autoplay]}
|
|
|
className="mySwiper"
|
|
|
>
|
|
|
{winImg.map((prize: any, index: number) => (
|