瀏覽代碼

Merge branch 'hotfix/修复触控通道断开重连' of Software/android-cloud-H5 into develop

zengzhixiang 2 年之前
父節點
當前提交
486c6527ef
共有 3 個文件被更改,包括 68 次插入41 次删除
  1. 32 32
      schemes/password.js
  2. 17 4
      static/screenAndroid/WXdraw.js
  3. 19 5
      static/screenIos/WXdraw.js

+ 32 - 32
schemes/password.js

@@ -68,7 +68,7 @@ export default class CustomScheme extends LocalScheme {
       this.options.endpoints.login,
     );
     this.updateTokens(response);
-    localStorage.setItem('auth.username', response.data.data.username);
+    // localStorage.setItem('auth.username', response.data.data.username);
 
     if (!this.requestHandler.interceptor) {
       this.initializeRequestInterceptor();
@@ -79,37 +79,37 @@ export default class CustomScheme extends LocalScheme {
     return response;
   }
 
-  fetchUser(endpoint) {
-    console.log(
-      '🚀 ~ file: password.js ~ line 83 ~ CustomScheme ~ fetchUser ~ endpoint',
-      endpoint,
-    );
-    if (!this.check().valid) {
-      return Promise.resolve();
-    }
-    if (!this.options.endpoints.user) {
-      this.$auth.setUser({});
-      return Promise.resolve();
-    }
-    return this.$auth
-      .requestWith(this.name, endpoint, this.options.endpoints.user)
-      .then((response) => {
-        const userData = getProp(response.data, this.options.user.property);
+  // fetchUser(endpoint) {
+  //   console.log(
+  //     '🚀 ~ file: password.js ~ line 83 ~ CustomScheme ~ fetchUser ~ endpoint',
+  //     endpoint,
+  //   );
+  //   if (!this.check().valid) {
+  //     return Promise.resolve();
+  //   }
+  //   if (!this.options.endpoints.user) {
+  //     this.$auth.setUser({});
+  //     return Promise.resolve();
+  //   }
+  //   return this.$auth
+  //     .requestWith(this.name, endpoint, this.options.endpoints.user)
+  //     .then((response) => {
+  //       const userData = getProp(response.data, this.options.user.property);
 
-        userData.username = localStorage.getItem('auth.username');
+  //       userData.username = localStorage.getItem('auth.username');
 
-        if (!userData) {
-          const error = new Error(
-            `User Data response does not contain field ${this.options.user.property}`,
-          );
-          return Promise.reject(error);
-        }
-        this.$auth.setUser(userData);
-        return response;
-      })
-      .catch((error) => {
-        this.$auth.callOnError(error, { method: 'fetchUser' });
-        return Promise.reject(error);
-      });
-  }
+  //       if (!userData) {
+  //         const error = new Error(
+  //           `User Data response does not contain field ${this.options.user.property}`,
+  //         );
+  //         return Promise.reject(error);
+  //       }
+  //       this.$auth.setUser(userData);
+  //       return response;
+  //     })
+  //     .catch((error) => {
+  //       this.$auth.callOnError(error, { method: 'fetchUser' });
+  //       return Promise.reject(error);
+  //     });
+  // }
 }

+ 17 - 4
static/screenAndroid/WXdraw.js

@@ -70,10 +70,23 @@ function doConnectDirectives() {
     );
   };
   wsss.onerror = function (evt) {
-    wsss.close();
-    throttle(doConnectDirectives, 100);
-    if (errorTime > 1000) {
-      quit();
+    // wsss.close();
+    // throttle(doConnectDirectives, 100);
+    // if (errorTime > 1000) {
+    //   quit();
+    // }
+  };
+  wsss.onclose = function (e) {
+    // console.log('🚀 ~ file: WXdraw.js ~ line 93 ~ onclose ~ e', e.code);
+    // new WebSocket(e.)
+    // doConnectDirectives();
+    if (e.code === 1006) {
+      // 异常关闭,重连
+      // doConnectDirectives();
+      throttle(doConnectDirectives, 100);
+      if (errorTime > 1000) {
+        quit();
+      }
     }
   };
   wsss.onmessage = function (res) {

+ 19 - 5
static/screenIos/WXdraw.js

@@ -78,11 +78,25 @@ function doConnectDirectives() {
       }),
     );
   };
-  wsss.onerror = function () {
-    wsss.close();
-    throttle(doConnectDirectives, 100);
-    if (errorTime > 1000) {
-      quit();
+  wsss.onerror = function (e) {
+    // console.log('🚀 ~ file: WXdraw.js ~ line 82 ~ onerror ~ e', e);
+    // wsss.close(1006);
+    // throttle(doConnectDirectives, 100);
+    // if (errorTime > 1000) {
+    //   quit();
+    // }
+  };
+  wsss.onclose = function (e) {
+    // console.log('🚀 ~ file: WXdraw.js ~ line 93 ~ onclose ~ e', e.code);
+    // new WebSocket(e.)
+    // doConnectDirectives();
+    if (e.code === 1006) {
+      // 异常关闭,重连
+      // doConnectDirectives();
+      throttle(doConnectDirectives, 100);
+      if (errorTime > 1000) {
+        quit();
+      }
     }
   };
   wsss.onmessage = function (res) {