year 1 månad sedan
förälder
incheckning
aa6efd672d

+ 16 - 2
src/app/[locale]/(navbar)/gameList2/Left.tsx

@@ -1,5 +1,6 @@
 "use client";
 import { GameListRep, GroupType } from "@/api/home";
+import { useRouter } from "@/i18n/routing";
 import { useProviderStore } from "@/stores/useProvider";
 import { server } from "@/utils/client";
 import clsx from "clsx";
@@ -9,6 +10,7 @@ import styles from "./page.module.scss";
 interface Props {
     actId: number;
     onChage?: (id: number) => void;
+    onInit?: () => void;
 }
 
 const getGames = async () => {
@@ -23,8 +25,9 @@ const getGames = async () => {
         });
 };
 
-const Left: React.FC<Props> = ({ actId, onChage }) => {
+const Left: React.FC<Props> = ({ actId, onChage, onInit }) => {
     const { providers, setProviders } = useProviderStore();
+    const router = useRouter();
 
     React.useEffect(() => {
         if (!providers || providers.length === 0) {
@@ -40,16 +43,27 @@ const Left: React.FC<Props> = ({ actId, onChage }) => {
         if (actId) {
             const res = providers.find((item) => item.id === actId);
             if (res) {
+                if (typeof onInit === "function") onInit();
                 return;
             }
         }
         if (providers?.length && typeof onChage === "function") {
             onChage(providers[0].id);
+            router.replace({
+                pathname: "/gameList2",
+                query: { provider_id: providers[0].id },
+            });
+            if (typeof onInit === "function") onInit();
         }
-    }, [providers, onChage, actId]);
+        // eslint-disable-next-line react-hooks/exhaustive-deps
+    }, [providers, onChage, actId, onInit]);
 
     const changeProvider = (item: GameListRep) => {
         if (providers?.length && typeof onChage === "function") {
+            router.replace({
+                pathname: "/gameList2",
+                query: { provider_id: item.id },
+            });
             onChage(item.id);
         }
     };

+ 2 - 2
src/app/[locale]/(navbar)/gameList2/page.module.scss

@@ -6,12 +6,12 @@
         box-sizing: border-box;
         height: 100%;
         overflow: auto;
-        padding: 0.1rem 0.1rem 0.5rem 0.1rem;
+        padding: 0.1rem 0.1rem 0.1rem 0.1rem;
     }
     .right {
         flex: 1;
         min-width: 0;
-        padding: 0.1rem 0.1rem 0.8rem 0;
+        padding: 0.1rem 0.1rem 0.2rem 0;
         overflow: auto;
         .rightBox {
             display: grid;

+ 1 - 0
src/app/[locale]/(navbar)/gameList2/page.tsx

@@ -19,6 +19,7 @@ const Page = () => {
                     setCurProvider(val);
                     setIsInited(true);
                 }}
+                onInit={() => setIsInited(true)}
             ></Left>
             <Right providerId={isInited ? curProvider : 0}></Right>
         </div>

+ 3 - 1
src/components/Layout/Sidebar.tsx

@@ -40,6 +40,7 @@ enum PageEnum {
     "download",
     "none",
     "profile",
+    "gameList2",
 }
 const Sidebar: FC<PropsWithChildren<Props>> = (props) => {
     // const t = useTranslations("Sidebar");
@@ -193,8 +194,9 @@ const Sidebar: FC<PropsWithChildren<Props>> = (props) => {
     }, []);
 
     const todoHandler = (item: any) => {
+        setCollapse(false);
         router.push({
-            pathname: `/gameList/?gameListFlag=${item.id}&type=2&bet_type=${item.bet_type}&name=${item.provider}`,
+            pathname: `/gameList2?provider_id=${item.id}`,
         });
     };