Browse Source

真人游戏添加关闭按钮

zcj03 6 months ago
parent
commit
0965eeec10
2 changed files with 25 additions and 2 deletions
  1. 24 1
      src/app/[locale]/game/page.tsx
  2. 1 1
      src/hooks/useGame.tsx

+ 24 - 1
src/app/[locale]/game/page.tsx

@@ -3,7 +3,7 @@
 import ActivityMask from "@/components/ModalPopup/ActivityModal";
 import { useRouter } from "@/i18n/routing";
 import { useSearchParams } from "next/navigation";
-import { useEffect } from "react";
+import { useEffect, useState } from "react";
 
 const Page = () => {
     const searchParams = useSearchParams();
@@ -24,9 +24,32 @@ const Page = () => {
         return () => window.removeEventListener("message", handler);
     }, []);
 
+    // 关闭iframe弹窗
+    const [categoryName, setCategoryName] = useState<string>("")
+    useEffect(() => {
+        const parmas: any = new URLSearchParams(url)
+        setCategoryName(parmas.get('category_name'))
+    }, [url]);
+    const goBlack = () => {
+        router.push("/")
+    }
     return (
         <>
             <div style={{ width: "100%", height: "100%" }}>
+                {/* 真人游戏添加关闭按钮 */}
+                {
+                    categoryName === "Live Casino Jogos" && <i 
+                        className={"iconfont icon-guanbi"} 
+                        style={{
+                            position: 'fixed',
+                            top: '0.1rem',
+                            right: '0.1rem',
+                            zIndex: "99999",
+                            fontSize: '.2rem'
+                        }} 
+                        onClick={goBlack}
+                    ></i>
+                }
                 <iframe src={url} width={"100%"} height={"100%"}></iframe>
             </div>
 

+ 1 - 1
src/hooks/useGame.tsx

@@ -21,7 +21,7 @@ const useGame = () => {
             .then((res) => {
                 Toast.clear();
                 if (res.data && res.data.game_url) {
-                    const url = `${encodeURI(res.data.game_url)}&brand=${brand}&return_url=${process.env.NEXT_PUBLIC_SHARE_URL}`;
+                    const url = `${encodeURI(res.data.game_url)}&brand=${brand}&return_url=${process.env.NEXT_PUBLIC_SHARE_URL}&category_name=${game.category_name}`;
                     const protocol = new URL(url).protocol;
                     if (
                         whiteUrls.indexOf(window.location.hostname) !== -1 ||