Переглянути джерело

fix: 修复游戏返回bug

Before 7 місяців тому
батько
коміт
64455d9c80

+ 1 - 3
src/app/[locale]/game/layout.tsx

@@ -1,4 +1,3 @@
-import HeaderBack from "@/components/HeaderBack";
 import { getTranslations } from "next-intl/server";
 import { ReactNode } from "react";
 export const generateMetadata = async () => {
@@ -17,8 +16,7 @@ export default async function Layout({
     const t = await getTranslations("Header");
     return (
         <>
-            <HeaderBack showBack={true} title={""} />
-            <main className={"main-header bg-[#282828]"}>{children}</main>
+            <main className={"h-[100%] bg-[#282828]"}>{children}</main>
         </>
     );
 }

+ 17 - 0
src/app/[locale]/game/page.tsx

@@ -1,11 +1,28 @@
 "use client";
 
 import ActivityMask from "@/components/Box/ActivityMask";
+import { useRouter } from "@/i18n/routing";
 import { useSearchParams } from "next/navigation";
+import { useEffect } from "react";
 
 const Page = () => {
     const searchParams = useSearchParams();
     const url = decodeURIComponent(`${searchParams}`);
+    const router = useRouter();
+    const handler = (event: MessageEvent) => {
+        if (event.data === "closeMessage") {
+            router.push("/");
+        }
+    };
+    useEffect(() => {
+        // @ts-ignore
+        window.quit = () => {
+            router.push("/");
+        };
+
+        window.addEventListener("message", handler);
+        return () => window.removeEventListener("message", handler);
+    }, []);
 
     return (
         <>

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

@@ -15,7 +15,7 @@ export interface CardProps {
     groupType?: Category["bet_type"];
 }
 
-const whiteUrls = ["192.168.0.84", "localhost"];
+const whiteUrls = ["192.168.0.84", "localhost", "192.168.0.46"];
 const Card: FC<PropsWithChildren<CardProps>> = (props) => {
     const { render, item, groupType } = props;