Jelajahi Sumber

开发模式下快速切换 正式 or 测试 环境

sa03 6 tahun lalu
induk
melakukan
bcee40cf09
2 mengubah file dengan 34 tambahan dan 25 penghapusan
  1. 4 7
      assets/scripts/Game.js
  2. 30 18
      assets/scripts/utils/Global.js

+ 4 - 7
assets/scripts/Game.js

@@ -3,8 +3,6 @@ const GameModule = require("./utils/GameModule");
 const FriendSystemApi = require('./net/FriendSystemApi');
 const ShareAction = require('./utils/ShareAction');
 const DWTool = require('./utils/DWTool');
-const DWAlert = require('./utils/DWAlert');
-const HomeApi = require("./net/HomeApi");
 const JobApi = require('./net/JobApi');
 const { GameNotificationKey, SenceMap, JobPageType } = require('./utils/GameEnum');
 const AlertManager = require('./utils/AlertManager');
@@ -167,15 +165,14 @@ cc.Class({
     },
 
     _initSocketMng() {
-        let ja0ckUrl = 'ws://172.16.15.170:8108/connect'
+        // let ja0ckUrl = 'ws://172.16.15.170:8108/connect'
 
-        let testUrl = 'wss://test-message-allstar.duowan.com/connect'
+        // let testUrl = 'wss://test-message-allstar.duowan.com/connect'
 
-        let pUrl = 'wss://message-allstar.duowan.com/connect'
+        // let pUrl = 'wss://message-allstar.duowan.com/connect'
 
         let Message = tutorial.Message;
-
-        let ws = this.ws = new WsManager(pUrl, {
+        let ws = this.ws = new WsManager(Global.socketUrl, {
             binaryType: 'arraybuffer',
             autoConnect: true,          // 自动连接
             reconnection: true,         // 断开自动重连

+ 30 - 18
assets/scripts/utils/Global.js

@@ -1,8 +1,10 @@
 const BuildingManager = require("../utils/BuildingManager");
 const ShareAction = require('./ShareAction');
 const Notikey = require('../utils/GameEnum').GameNotificationKey;
+const DWTool = require('./utils/DWTool');
 
-window.Global = {
+var Global = Global || {}
+Global = {
 
     // 建筑管理
     BuildingManager: BuildingManager.instance,
@@ -40,25 +42,35 @@ window.Global = {
     friendList: []
 };
 
+// 开发模式下快速切换 正式 or 测试 环境
+if(CC_DEV && DWTool.getUrlParam('debug') != null) {
+    Global.debug = !!~~DWTool.getUrlParam('debug');
+}
+
+Global.socketUrl = Global.debug ? 
+'wss://test-message-allstar.duowan.com/connect' : 'wss://message-allstar.duowan.com/connect';
+
+window.Global = Global;
+
 if (cc.sys.platform === cc.sys.WECHAT_GAME) {
     wx.onShow(({ query, shareTicket }) => {
-        if (typeof wx.getUpdateManager === 'function') {
-            const updateManager = wx.getUpdateManager()
-
-            updateManager.onCheckForUpdate(function (res) {
-                // 请求完新版本信息的回调
-                console.log('hasUpdate: ' + JSON.stringify(res.hasUpdate));
-            })
-
-            updateManager.onUpdateReady(function () {
-                // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
-                updateManager.applyUpdate()
-            })
-
-            updateManager.onUpdateFailed(function () {
-                // 新的版本下载失败
-            })
-        }
+        // if (typeof wx.getUpdateManager === 'function') {
+        //     const updateManager = wx.getUpdateManager()
+
+        //     updateManager.onCheckForUpdate(function (res) {
+        //         // 请求完新版本信息的回调
+        //         console.log('hasUpdate: ' + JSON.stringify(res.hasUpdate));
+        //     })
+
+        //     updateManager.onUpdateReady(function () {
+        //         // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+        //         updateManager.applyUpdate()
+        //     })
+
+        //     updateManager.onUpdateFailed(function () {
+        //         // 新的版本下载失败
+        //     })
+        // }
 
         console.log('Global onShow' + JSON.stringify(query) + '======================================');
         if (query != undefined && query != null) {