zhejiushizhuce пре 2 година
родитељ
комит
8405d1d957
3 измењених фајлова са 23 додато и 11 уклоњено
  1. 2 1
      src/api/config.js
  2. 11 10
      src/pages/Sport.jsx
  3. 10 0
      src/utils/helpers.js

+ 2 - 1
src/api/config.js

@@ -1,3 +1,4 @@
+import {getDomainSuffix} from "@utils/helpers";
 
 export const REQ_STATUS={
     NONE:"NONE",
@@ -7,7 +8,7 @@ export const REQ_STATUS={
 }
 
 // export const BASE_API="https://api.24680.com/";
-export const BASE_API="https://br.24b.pro/";
+export const BASE_API=getDomainSuffix()==="pro"?"https://test.24b.pro/":"https://br.24b.pro/";
 
 export const BASE_PREFIX="game/";
 

+ 11 - 10
src/pages/Sport.jsx

@@ -6,6 +6,7 @@ import {useDispatch, useSelector} from "react-redux";
 import {useLocation} from "react-router-dom";
 import {ROUTE_PATH} from "@constants/routes";
 import {isLogined} from "@features/mainSlice";
+import {getDomainSuffix} from "@utils/helpers";
 
 const Sport = ({...props}) => {
     const [isReToken, setIsReToken] = useState(false);
@@ -28,16 +29,16 @@ const Sport = ({...props}) => {
     const resetSport=()=>{
         initSport();
     }
-    const getDomainSuffix=()=>{
-        // 获取当前域名
-        let hostname = window.location.hostname;
-        // 使用点分隔符分割域名
-        let parts = hostname.split('.');
-        // 取得最后一个部分,即后缀
-        let suffix = parts[parts.length - 1];
-
-        return suffix;
-    }
+    // const getDomainSuffix=()=>{
+    //     // 获取当前域名
+    //     let hostname = window.location.hostname;
+    //     // 使用点分隔符分割域名
+    //     let parts = hostname.split('.');
+    //     // 取得最后一个部分,即后缀
+    //     let suffix = parts[parts.length - 1];
+    //
+    //     return suffix;
+    // }
     const checkShowSport=()=>{
         return isReToken&&isSrcLoaded;
     }

+ 10 - 0
src/utils/helpers.js

@@ -453,3 +453,13 @@ export const getBrazilTimeStamp = (dateString) => {
     const timestamp = date.getTime();
     return timestamp;
 };
+export const getDomainSuffix=()=>{
+    // 获取当前域名
+    let hostname = window.location.hostname;
+    // 使用点分隔符分割域名
+    let parts = hostname.split('.');
+    // 取得最后一个部分,即后缀
+    let suffix = parts[parts.length - 1];
+
+    return suffix;
+}