Sfoglia il codice sorgente

fix:游戏跳转增加play

ansoni 2 mesi fa
parent
commit
c72b168ace
2 ha cambiato i file con 19 aggiunte e 7 eliminazioni
  1. 10 0
      next.config.mjs
  2. 9 7
      src/hooks/useGame.tsx

+ 10 - 0
next.config.mjs

@@ -8,6 +8,7 @@ const nextConfig = {
     env: {
         BUILD_ENV: process.env.BUILD_ENV,
     },
+
     transpilePackages: ["antd-mobile"],
     sassOptions: {
         quietDeps: true,
@@ -24,6 +25,15 @@ const nextConfig = {
             static: 180,
         },
         scrollRestoration: true,
+        optimizePackageImports: [
+            "antd-mobile",
+            "dayjs",
+            "bignumber.js",
+            "@lucky-canvas/react",
+            "@number-flow/react",
+            "framer-motion",
+            "next-intl",
+        ],
     },
     images: {
         domains: [

+ 9 - 7
src/hooks/useGame.tsx

@@ -39,7 +39,7 @@ const useGame = () => {
         const lang = getCookies("language") || defaultLocale;
         getGameDetailApi({ ...params, language: lang === "br" ? "pt" : lang })
             .then((res) => {
-                console.log('category_name',game)
+                console.log("category_name", game);
 
                 Toast.clear();
                 if (res.data && res.data.game_url) {
@@ -47,7 +47,7 @@ const useGame = () => {
                     const game_url = res.data.game_url;
 
                     // 获取游戏的品牌
-                    const gameId= game?.game_id || '';
+                    const gameId = game?.game_id || "";
 
                     // 然后是文档对象
                     if (game_url.indexOf("!doctype") !== -1) {
@@ -60,11 +60,13 @@ const useGame = () => {
 
                     // 如果是pp游戏,则当前窗口打开新的地址,不需要加return_url
                     // gid 如果开头是1的6位数的数字,则认为是pp游戏
-                    let isPP = /^1\d{5}$/.test(gameId)
-                    if(!!isPP){
-                      // const ppUrl = `${encodeURI(res.data.game_url)}&category_name=${game.provider}`;
-                      window.open(url,'_self');
-                      return
+                    let isPP = /^1\d{5}$/.test(gameId);
+                    // 如果是play游戏,则当前窗口打开新的地址
+                    const isPlay = /^5\d{5}$/.test(gameId);
+                    if (isPP || isPlay) {
+                        // const ppUrl = `${encodeURI(res.data.game_url)}&category_name=${game.provider}`;
+                        window.open(url, "_self");
+                        return;
                     }
 
                     if (new RegExp("https").test(game_url)) {