ansoni 1 mese fa
parent
commit
d1977538b3

+ 1 - 2
src/app/[locale]/(TabBar)/[[...share]]/@actionWidget/page.tsx

@@ -17,8 +17,7 @@ const terms = [
 ];
 
 const Page = async () => {
-    const services = await getServicesApi();
-    const t = await getTranslations("HomePage");
+    const [t, services] = await Promise.all([getTranslations("HomePage"), getServicesApi()]);
     return (
         <div className={"px-[0.12rem] py-[0.08rem]"}>
             {/*about*/}

+ 11 - 6
src/app/[locale]/(TabBar)/[[...share]]/_home/HomeMessage.tsx

@@ -3,19 +3,24 @@ import { NoticeRep } from "@/api/home";
 import { useGlobalNoticeStore } from "@/stores/useGlobalNoticeStore";
 import { AnimatePresence, motion } from "framer-motion";
 import { FC } from "react";
+import { shallow } from "zustand/shallow";
 
 interface Props {
     notices: NoticeRep[];
 }
 
 const HomeMessage: FC<Props> = (props) => {
-    const { sourceMap, setSourceMap, notices, hasValue } = useGlobalNoticeStore((state) => ({
-        sourceMap: state.sourceMap,
-        setSourceMap: state.setSourceMap,
-        hasValue: state.hasValue,
-        notices: state.notices,
-    }));
+    const { sourceMap, setSourceMap, notices, hasValue } = useGlobalNoticeStore(
+        (state) => ({
+            sourceMap: state.sourceMap,
+            setSourceMap: state.setSourceMap,
+            hasValue: state.hasValue,
+            notices: state.notices,
+        }),
+        shallow
+    );
 
+    console.log(`🚀🚀🚀🚀🚀-> in HomeMessage.tsx on 19`);
     const newNotices = notices
         .filter((item) => {
             return !item.is_read && !hasValue(item.id) && item.is_window !== 2;

+ 1 - 21
src/app/[locale]/(TabBar)/[[...share]]/layout.tsx

@@ -3,27 +3,7 @@ import { getTranslations } from "next-intl/server";
 import { FC, PropsWithChildren, ReactNode, Suspense } from "react";
 import DownloadSection from "./_home/DownloadSection";
 
-import { GroupType } from "@/api/home";
-import {
-    NoticePlaceHolder,
-    PrizePlaceHolder,
-    SwiperPlaceHolder,
-} from "@/app/[locale]/(TabBar)/[[...share]]/Placeholder";
-import { server } from "@/utils/server";
-
-const TIME = 0;
-const getGames = async () => {
-    return server
-        .request<GroupType[]>({
-            url: "/v1/api/front/game_list",
-            method: "POST",
-            next: { revalidate: TIME },
-        })
-        .then((res) => {
-            if (res.code === 200) return res.data;
-            return [];
-        });
-};
+import { NoticePlaceHolder, PrizePlaceHolder, SwiperPlaceHolder } from "./Placeholder";
 
 export const generateMetadata = async () => {
     const t = await getTranslations("titles");

+ 0 - 2
src/app/[locale]/(TabBar)/[[...share]]/page.tsx

@@ -29,8 +29,6 @@ const getPrizeApi = () => {
 
 export default async function Page(props: any) {
     const group = await getGames();
-
-    // const result = await getPrizeApi();
     return (
         <HomeTabs
             tabs={group}

+ 50 - 27
src/app/[locale]/(TabBar)/profile/ProfileHeader.tsx

@@ -21,17 +21,20 @@ import { Badge, Button, Mask, ProgressBar, Toast } from "antd-mobile";
 import { useTranslations } from "next-intl";
 import Image from "next/image";
 import { Fragment, useEffect, useRef, useState } from "react";
-
+import { shallow } from "zustand/shallow";
 type Props = {
     userInfo: UserInfoRep;
 };
 const VipCard = () => {
     const t = useTranslations("ProfilePage");
-    const userVip = useVipStore((state) => state.vipData);
+    const vip_score_exp = useVipStore((state) => state.vipData!.vip_score_exp);
+    const vip_level = useVipStore((state) => state.vipData!.vip_level);
+    const vip_next_level = useVipStore((state) => state.vipData!.vip_next_level);
+    const vip_exp = useVipStore((state) => state.vipData!.vip_exp);
 
     // Vip 图标
     const vipIconElement = vipImages.map((item, index) => {
-        if (item.leve === userVip?.vip_level) {
+        if (item.leve === vip_level) {
             return (
                 <Fragment key={index}>
                     <Image src={item.src} alt={"vip"} height={110} width={100} />
@@ -43,7 +46,7 @@ const VipCard = () => {
         }
     });
 
-    if (!userVip) return null;
+    // if (!userVip) return null;
     return (
         <div className={"vip-card"}>
             <div className={"vip-card__icon"}>{vipIconElement}</div>
@@ -51,7 +54,7 @@ const VipCard = () => {
                 {/*<div className={"process-top"}>{userVip.vip_exp}xp</div>*/}
                 <div>
                     <ProgressBar
-                        percent={percentage(userVip?.vip_exp, userVip?.vip_score_exp)}
+                        percent={percentage(vip_exp, vip_score_exp)}
                         style={{
                             "--fill-color": "#bd37e0",
                             "--track-color": "#65609b",
@@ -60,15 +63,15 @@ const VipCard = () => {
                     />
                 </div>
                 <div className={"process-bottom text-[#e581ff]"}>
-                    <span>VIP{userVip?.vip_level}</span>
+                    <span>VIP{vip_level}</span>
                     <span className={"process-bottom-desc"}>
                         {t("expTips", {
-                            exp: flatPoint(userVip.vip_score_exp - userVip.vip_exp),
+                            exp: flatPoint(vip_score_exp - vip_exp),
                         })}
                     </span>
                     <span>
                         VIP
-                        {userVip.vip_next_level}
+                        {vip_next_level}
                     </span>
                 </div>
             </div>
@@ -77,8 +80,30 @@ const VipCard = () => {
 };
 
 const WalletCard = () => {
-    // const { userMoney } = props;
-    const userMoney = useWalletStore((state) => state.wallet);
+    const {
+        score,
+        point,
+        free_score,
+        free_transfer_min,
+        lose_transfer_min,
+        is_point_transfer,
+        is_free_transfer,
+        is_lose_transfer,
+        lose_score,
+    } = useWalletStore((state) => {
+        return {
+            score: state.wallet.score,
+            point: state.wallet.point,
+            free_score: state.wallet.free_score,
+            free_transfer_min: state.wallet.free_transfer_min,
+            lose_transfer_min: state.wallet.lose_transfer_min,
+            is_point_transfer: state.wallet.is_point_transfer,
+            is_free_transfer: state.wallet.is_free_transfer,
+            is_lose_transfer: state.wallet.is_lose_transfer,
+            lose_score: state.wallet.lose_score,
+        };
+    }, shallow);
+
     const t = useTranslations("ProfilePage");
     const tcdoe = useTranslations();
 
@@ -159,19 +184,19 @@ const WalletCard = () => {
                     </div>
                 }
             >
-                {/*现金*/}
-                {tipsStatus === WalletEnum.Balance ? <BalanceContent wallet={userMoney} /> : null}
-                {/*  彩金*/}
+                {/*/!*现金*!/*/}
+                {tipsStatus === WalletEnum.Balance ? <BalanceContent /> : null}
+                {/*/!*  彩金*!/*/}
                 {tipsStatus === WalletEnum.Bonus ? (
-                    <BonusContent wallet={userMoney} handleAcquire={handleAcquire} />
+                    <BonusContent handleAcquire={handleAcquire} />
                 ) : null}
-                {/* 免费币 */}
+                {/*/!* 免费币 *!/*/}
                 {tipsStatus === WalletEnum.Free ? (
-                    <FreeContent wallet={userMoney} handleAcquire={handleAcquire} />
+                    <FreeContent handleAcquire={handleAcquire} />
                 ) : null}
-                {/*  重玩币 */}
+                {/*/!*  重玩币 *!/*/}
                 {tipsStatus === WalletEnum.Replay ? (
-                    <ReplayContent wallet={userMoney} handleAcquire={handleAcquire} />
+                    <ReplayContent handleAcquire={handleAcquire} />
                 ) : null}
             </TipsModal>
             {/*   提现拦截 */}
@@ -217,7 +242,7 @@ const WalletCard = () => {
                             </div>
                             <div className="num">
                                 <span className="uppercase">brl </span>
-                                <span>{userMoney?.score || 0.0}</span>
+                                <span>{score}</span>
                             </div>
                         </section>
                     </div>
@@ -226,7 +251,7 @@ const WalletCard = () => {
                         onClick={() => modalHandler(WalletEnum.Bonus)}
                     >
                         <Badge
-                            content={userMoney?.is_point_transfer ? Badge.dot : null}
+                            content={is_point_transfer ? Badge.dot : null}
                             style={{ right: "10px" }}
                         >
                             <div className="wallet-right-icon">
@@ -240,7 +265,7 @@ const WalletCard = () => {
                             </div>
                             <div className="num">
                                 <span className="uppercase">brl </span>
-                                <span>{userMoney?.point || 0.0}</span>
+                                <span>{point || 0.0}</span>
                             </div>
                         </section>
                     </div>
@@ -250,8 +275,7 @@ const WalletCard = () => {
                     >
                         <Badge
                             content={
-                                userMoney.is_free_transfer &&
-                                userMoney.free_score >= (userMoney?.free_transfer_min || 0)
+                                is_free_transfer && free_score >= (free_transfer_min || 0)
                                     ? Badge.dot
                                     : null
                             }
@@ -268,7 +292,7 @@ const WalletCard = () => {
                             </div>
                             <div className="num">
                                 <span className="uppercase">brl </span>
-                                <span>{userMoney.free_score || 0.0}</span>
+                                <span>{free_score || 0.0}</span>
                             </div>
                         </section>
                     </div>
@@ -278,8 +302,7 @@ const WalletCard = () => {
                     >
                         <Badge
                             content={
-                                userMoney.is_lose_transfer &&
-                                userMoney.lose_score >= (userMoney?.lose_transfer_min || 0)
+                                is_lose_transfer && lose_score >= (lose_transfer_min || 0)
                                     ? Badge.dot
                                     : null
                             }
@@ -297,7 +320,7 @@ const WalletCard = () => {
                             </div>
                             <div className="num">
                                 <span className="uppercase">brl </span>
-                                <span>{userMoney.lose_score || 0.0}</span>
+                                <span>{lose_score || 0.0}</span>
                             </div>
                         </section>
                     </div>

+ 10 - 6
src/app/[locale]/(TabBar)/profile/component/ItemCom/index.tsx

@@ -8,6 +8,7 @@ import { server } from "@/utils/client";
 import { Badge, Toast } from "antd-mobile";
 import { useTranslations } from "next-intl";
 import { FC } from "react";
+import { shallow } from "zustand/shallow";
 import "./style.scss";
 
 /**
@@ -46,12 +47,15 @@ const ItemCom: FC<ItemComProps> = ({ type = "login" }) => {
     const t = useTranslations("ProfilePage");
     const tall = useTranslations();
     const router = useRouter();
-    const { unread, userUnread } = useGlobalNoticeStore((state) => ({
-        unread: state.unread,
-        userUnread: state.userUnred,
-    }));
+    const { unread, userUnread } = useGlobalNoticeStore(
+        (state) => ({
+            unread: state.unread,
+            userUnread: state.userUnred,
+        }),
+        shallow
+    );
 
-    const vipInfo = useVipStore((state) => state.vipData);
+    const vip_cashback = useVipStore((state) => state.vipData?.vip_cashback ?? 0);
 
     const links = [
         // { label: "gratis", desc: "gratisDesc", icon: "", url: "/", content: null },
@@ -72,7 +76,7 @@ const ItemCom: FC<ItemComProps> = ({ type = "login" }) => {
             content: null,
         },
         {
-            label: t("cashback", { max: vipInfo?.vip_cashback ?? 0 }),
+            label: t("cashback", { max: vip_cashback }),
             desc: "",
             icon: "icon-qiandai",
             color: "#ff9b23",

+ 4 - 2
src/app/[locale]/(TabBar)/profile/layout.tsx

@@ -1,6 +1,6 @@
 import HeaderBack from "@/components/HeaderBack";
 import { getTranslations } from "next-intl/server";
-import { ReactNode } from "react";
+import { ReactNode, Suspense } from "react";
 
 export const generateMetadata = async () => {
     const t = await getTranslations("titles");
@@ -18,7 +18,9 @@ export default async function LocaleLayout({
     return (
         <div className="profilPage h-[100%] overflow-auto bg-[url('/home/bg.jpg')]">
             <HeaderBack showBack={true} useBg={true} title="Perfil" />
-            <main className={"main-header"}>{children}</main>
+            <main className={"main-header"}>
+                <Suspense fallback={<div>Loading...</div>}>{children}</Suspense>
+            </main>
         </div>
     );
 }

+ 11 - 17
src/app/[locale]/(TabBar)/profile/page.tsx

@@ -1,23 +1,17 @@
-"use client";
-import { userInfoApi } from "@/api/login";
-import { useRequest } from "ahooks";
-import ItemCom from "./component/ItemCom";
-import ModalCom from "./component/ModalCom";
+import { UserInfoRep } from "@/api/user";
+import { server } from "@/utils/server";
 import "./page.scss";
-import { ProfileHeader } from "./ProfileHeader";
-
-const Profile = () => {
-    const { data: userInfo } = useRequest<any, any>(userInfoApi, {
-        pollingErrorRetryCount: 1,
+const getUserInfo = async () => {
+    return server.request<UserInfoRep>({
+        url: "/v1/api/user/user_info",
+        method: "POST",
+        next: { revalidate: 0 },
     });
+};
+const Profile = async () => {
+    const userInfo = await getUserInfo();
 
-    return (
-        <div className="profile-box">
-            <ProfileHeader userInfo={userInfo?.data} />
-            <ItemCom />
-            <ModalCom />
-        </div>
-    );
+    return <div className="profile-box"></div>;
 };
 
 export default Profile;

+ 0 - 3
src/app/[locale]/(TabBar)/profile/template.tsx

@@ -1,3 +0,0 @@
-export default function Template({ children }: { children: React.ReactNode }) {
-    return children;
-}

+ 4 - 4
src/app/[locale]/(TabBar)/replayGames/page.tsx

@@ -60,13 +60,13 @@ const Header = () => {
                 }
             >
                 {/*现金*/}
-                {tipsStatus === WalletEnum.Balance ? <BalanceContent wallet={wallet} /> : null}
+                {tipsStatus === WalletEnum.Balance ? <BalanceContent /> : null}
                 {/*  彩金*/}
-                {tipsStatus === WalletEnum.Bonus ? <BonusContent wallet={wallet} /> : null}
+                {tipsStatus === WalletEnum.Bonus ? <BonusContent /> : null}
                 {/* 免费币 */}
-                {tipsStatus === WalletEnum.Free ? <FreeContent wallet={wallet} /> : null}
+                {tipsStatus === WalletEnum.Free ? <FreeContent /> : null}
                 {/*  重玩币 */}
-                {tipsStatus === WalletEnum.Replay ? <ReplayContent wallet={wallet} /> : null}
+                {tipsStatus === WalletEnum.Replay ? <ReplayContent /> : null}
             </TipsModal>
         </>
     );

+ 11 - 4
src/app/[locale]/providers.tsx

@@ -150,7 +150,7 @@ const PollingClient = () => {
     const setWallet = useWalletStore((state) => state.setWallet);
 
     // 系统通知
-    const { unread, userUnred, setNotices, setUserUnread, promotion_count, setPromotionCount } =
+    const { userUnred, notices, setNotices, setUserUnread, promotion_count, setPromotionCount } =
         useGlobalNoticeStore((state) => ({
             unread: state.unread,
             setNotices: state.setNotices,
@@ -158,6 +158,7 @@ const PollingClient = () => {
             setPromotionCount: state.setPromotionCount,
             userUnred: state.userUnred,
             promotion_count: state.promotion_count,
+            notices: state.notices,
         }));
 
     //   事件上报
@@ -194,10 +195,16 @@ const PollingClient = () => {
             setPollingRefresh(run);
             setPollingCancel(cancel);
             // 钱包信息
-            setWallet(user_info);
+            if (user_info) {
+                setWallet(user_info);
+            }
             //  系统通知
-            setNotices(system_notice?.data || [], system_notice?.summery?.unread || 0);
-            setPromotionCount(system_notice?.summery?.promotion_count || 0);
+            if (notices.length !== system_notice?.data.length) {
+                setNotices(system_notice?.data || [], system_notice?.summery?.unread || 0);
+            }
+            if (promotion_count !== system_notice?.summery?.promotion_count) {
+                setPromotionCount(system_notice?.summery?.promotion_count || 0);
+            }
             // 站内信
             setUserUnread(user_letter?.summery?.unread || 0);
             // 活动相关 - 定时免费送

+ 9 - 1
src/components/Card/Card.tsx

@@ -8,6 +8,7 @@ import { getToken } from "@/utils/Cookies";
 import { Button, Image, Popup, Toast } from "antd-mobile";
 import { useTranslations } from "next-intl";
 import { FC, PropsWithChildren, ReactNode, useEffect, useRef, useState } from "react";
+import { shallow } from "zustand/shallow";
 import TipsModal, { ModalProps } from "../TipsModal";
 import styles from "./style.module.scss";
 export interface CardProps {
@@ -23,7 +24,14 @@ const Card: FC<PropsWithChildren<CardProps>> = (props) => {
 
     const t = useTranslations("Game");
     const brandRef = useRef<GameListRep | null>(null);
-    const wallet = useWalletStore((state) => state.wallet);
+    const wallet = useWalletStore((state) => {
+        return {
+            score: state.wallet?.score,
+            point: state.wallet?.point,
+            free_score: state.wallet?.free_score,
+            lose_score: state.wallet?.lose_score,
+        };
+    }, shallow);
     // 判断是否有未结算的对局
     const gameModelRef = useRef<ModalProps>(null);
     const gameRef = useRef<(GameListRep & { mode: GameRequest["mode"] }) | null>(null);

+ 1 - 1
src/components/ModalPopup/SlotsModal/index.tsx

@@ -283,7 +283,7 @@ const SlotsClient: FC<SlotsClientProps> = (props) => {
                         alt={""}
                     />
                     {/*light*/}
-                    <div className={"absolute top-0 h-[2.69rem] w-[100%]"}>
+                    <div className={"absolute top-[0px] h-[2.69rem] w-[100%]"}>
                         <img
                             src={"/slots/light-1.png"}
                             alt={""}

+ 27 - 12
src/components/ModalPopup/WalletDescribeModal/index.tsx

@@ -1,9 +1,11 @@
-import { Wallet, cleanBounsApi, getUserMoneyApi, toggleUserBounsApi } from "@/api/user";
+import { cleanBounsApi, toggleUserBounsApi } from "@/api/user";
+import { usePollingStore } from "@/stores/usePollingStore";
 import { useWalletStore } from "@/stores/useWalletStore";
 import { percentage } from "@/utils/methods";
 import { Dialog, ProgressBar, Toast } from "antd-mobile";
 import { useTranslations } from "next-intl";
 import React from "react";
+import { shallow } from "zustand/shallow";
 import "./style.scss";
 
 const Progress = ({ percent, textColor = "#fff" }: { percent: number; textColor?: string }) => {
@@ -54,8 +56,15 @@ export const WalletContent = ({
     );
 };
 // 现金
-export const BalanceContent = (props: { wallet: Wallet }) => {
-    const { wallet } = props;
+export const BalanceContent = () => {
+    // const { wallet } = props;
+    const wallet = useWalletStore((state) => {
+        return {
+            score: state.wallet.score,
+            target_score_rollover: state.wallet.target_score_rollover,
+            current_score_rollover: state.wallet.current_score_rollover,
+        };
+    }, shallow);
     const t = useTranslations("ProfilePage");
     return (
         <>
@@ -69,13 +78,17 @@ export const BalanceContent = (props: { wallet: Wallet }) => {
     );
 };
 
-export const BonusContent = (props: { wallet: Wallet; handleAcquire?: any }) => {
-    const { wallet, handleAcquire } = props;
+export const BonusContent = (props: { handleAcquire?: any }) => {
+    const { handleAcquire } = props;
+    const { setWallet, wallet } = useWalletStore((state) => ({
+        setWallet: state.setWallet,
+        wallet: state.wallet,
+    }));
     const [switchValue, setSwitchValue] = React.useState<boolean>(
         wallet.is_open_no_bonus === 1 || false
     );
+    const refresh = usePollingStore((state) => state.refresh);
     const [isLoading, setIsLoading] = React.useState<boolean>(false);
-    const { setWallet } = useWalletStore((state) => ({ setWallet: state.setWallet }));
     const t = useTranslations("ProfilePage");
 
     const changeValue = async (value: boolean) => {
@@ -129,8 +142,8 @@ export const BonusContent = (props: { wallet: Wallet; handleAcquire?: any }) =>
             content: t("success"),
             icon: "success",
         });
-        const walletRes = await getUserMoneyApi();
-        setWallet(walletRes?.data);
+
+        refresh && refresh();
     };
 
     return (
@@ -192,16 +205,17 @@ export const BonusContent = (props: { wallet: Wallet; handleAcquire?: any }) =>
 };
 
 export const FreeContent = ({
-    wallet,
     handleAcquire,
     textColor = "#fff",
 }: {
-    wallet: Wallet;
     handleAcquire?: any;
     textColor?: string;
 }) => {
     // const { wallet, handleAcquire } = props;
     const t = useTranslations("ProfilePage");
+    const { wallet } = useWalletStore((state) => ({
+        wallet: state.wallet,
+    }));
     return (
         <div>
             <WalletContent
@@ -242,15 +256,16 @@ export const FreeContent = ({
     );
 };
 export const ReplayContent = ({
-    wallet,
     handleAcquire,
     textColor = "#fff",
 }: {
-    wallet: Wallet;
     handleAcquire?: any;
     textColor?: string;
 }) => {
     const t = useTranslations("ProfilePage");
+    const { wallet } = useWalletStore((state) => ({
+        wallet: state.wallet,
+    }));
     return (
         <div>
             <WalletContent

+ 14 - 4
tailwind.config.ts

@@ -48,12 +48,26 @@ const config: Config = {
         "./src/app/**/*.{js,ts,jsx,tsx,mdx}",
     ],
     theme: {
+        space: size,
+        padding: size,
+        height: size,
+        minWidth: size,
+        lineHeight: size,
+        width: size,
+        gap: size,
+        minHeight: size,
+        fontSize: size,
         extend: {
             backgroundImage: {
                 "gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
                 "gradient-conic":
                     "conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
             },
+            padding: {
+                "spacing-x": "0.12rem",
+                "spacing-y": "0.08rem",
+            },
+
             textShadow: {},
             keyframes: keyframes,
             animation: {
@@ -65,10 +79,6 @@ const config: Config = {
             "primary-color": "var(--primary-color)",
             "linear-color": "linear-gradient(180deg, #ffaa30, #ffe6be)",
         },
-        spacing: {
-            "spacing-x": "0.12rem",
-            "spacing-y": "0.08rem",
-        },
     },
     plugins: [
         plugin(function ({ addUtilities }: any) {