Browse Source

修改bug

huangxiaojing 3 years ago
parent
commit
13bc360f57
2 changed files with 32 additions and 10 deletions
  1. 25 5
      screenAndroid/WXtrialInterface.html
  2. 7 5
      screenIos/WXtrialInterface.html

+ 25 - 5
screenAndroid/WXtrialInterface.html

@@ -435,14 +435,34 @@
 
     // 处理页面可见属性的改变
     document.addEventListener("visibilitychange", function () {
-      console.log(document[hidden]);
-      if (document[hidden]) {
-        quit();
-        ws.close();
-        wsss.close();
+
+      if (navigator.userAgent.toLowerCase().includes('toutiaomicroapp')) {
+        visibilitychange();
+      } else if (window.__wxjs_environment === 'miniprogram') {
+        visibilitychange();
+      } else {
+        if (document[hidden]) {
+          ws.close();
+          wsss.close();
+          uni.webView.navigateTo({
+            url: '/pages/index/index'
+          });
+        }
       }
     }, false);
 
+    function visibilitychange() {
+      if (document.visibilityState == "visible") {
+        var buffer = RequestIFrame();
+        ws.send(buffer);
+        isVisuable = true;
+      } else {
+        isVisuable = false;
+        isFeed = false;
+        myVideo.pause();
+      }
+    }
+
     myVideo.addEventListener('pause', function () {
       isFeed = false;
     });

+ 7 - 5
screenIos/WXtrialInterface.html

@@ -1099,11 +1099,13 @@
     // 处理页面可见属性的改变
     document.addEventListener("visibilitychange", function () {
       if (document[hidden]) {
-        quit();
-        wsss.close();
-        decodeWoker.postMessage('close');
-        decodeWoker.terminate();
-        webSocketWorker.terminate();
+        if (!navigator.userAgent.toLowerCase().includes('toutiaomicroapp') || window.__wxjs_environment !== 'miniprogram') {
+          ws.close();
+          wsss.close();
+          uni.webView.navigateTo({
+            url: '/pages/index/index'
+          });
+        }
       }
     }, false);