From 8ee79710640b73f616d268460adb91b58d1df521 Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Thu, 02 Dec 2021 16:39:36 +0800
Subject: [PATCH] 微调底层文件结构,微调测试环境判断

---
 bases/Fetcher.js          |   18 ++++++++++++++++--
 bases/BridgeCenterBase.js |    4 ++--
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/common/BridgeTelling.js b/bases/BridgeCenterBase.js
similarity index 95%
rename from common/BridgeTelling.js
rename to bases/BridgeCenterBase.js
index 5218cf1..5ab17cd 100644
--- a/common/BridgeTelling.js
+++ b/bases/BridgeCenterBase.js
@@ -1,5 +1,5 @@
 /**
- * BridgeTelling - 跨端通讯,通知接收基类
+ * BridgeCenterBase - 跨端通讯,通知接收基类
  * @author Tevin
  */
 
@@ -7,7 +7,7 @@
 import { $bridge } from '@components/common/Bridge';
 import { Fetcher } from '@components/bases/Fetcher';
 
-export class BridgeTelling {
+export class BridgeCenterBase {
     constructor(tellings) {
         this._init(tellings);
     }
diff --git a/bases/Fetcher.js b/bases/Fetcher.js
index a20fe5b..0d123b0 100644
--- a/bases/Fetcher.js
+++ b/bases/Fetcher.js
@@ -578,8 +578,22 @@
     static inDevMod = (() => {
         // 网页
         if (process.env.TARO_ENV === 'h5') {
-            // 当没有 url 指定时,只有内网 ip 和 33**/35** 的端口号,视为本地开发模式
-            return /^(192|127|localhost).*?:3[35]\d{2}$/i.test(window.location.host);
+            // http协议访问
+            if (window.location.protocol.indexOf('http') > 0) {
+                // 当内网 ip 且使用 33**/35** 的端口号时,视为本地开发模式
+                return /^(192|127|localhost).*?:3[35]\d{2}$/i.test(window.location.host);
+            }
+            // 非http协议访问
+            else {
+                // 开发编译
+                if (process.env.NODE_ENV === 'development') {
+                    return true;
+                }
+                // 生产编译
+                else if (process.env.NODE_ENV === 'production') {
+                    return false;
+                }
+            }
         }
         // 小程序
         else if (process.env.TARO_ENV === 'weapp') {

--
Gitblit v1.9.1