瀏覽代碼

feat:在云手机推流无点击操作提示弹窗

leo 1 年之前
父節點
當前提交
5ff891974f
共有 1 個文件被更改,包括 36 次插入3 次删除
  1. 36 3
      static/webRtcYJ/WXdraw.js

+ 36 - 3
static/webRtcYJ/WXdraw.js

@@ -1,3 +1,33 @@
+let noOperationSetTimeoutTime = null
+let noOperationSetIntervalTime = null
+let isFiringNoOperationSetTimeout = false
+
+function noOperationSetTimeout() {
+  clearTimeout(noOperationSetTimeoutTime)
+  clearTimeout(noOperationSetIntervalTime)
+  noOperationSetTimeoutTime = setTimeout(() => {
+    let index = 10
+    $.modal({
+      text: "由于您长时间未操作,将自动断开视频链接(不影响云手机内应用运行)",
+      buttons: [
+        { text: "继续操作", className: "default", onClick: function () { noOperationSetTimeout() } },
+        { text: "退出", className: 'operate-time-exit', onClick: function () { quit() } },
+      ]
+    });
+    $('.operate-time-exit').text("退出(10秒)")
+    noOperationSetIntervalTime = setInterval(() => {
+      if (index <= 0) {
+        $('.operate-time-exit').text(`退出`)
+        clearInterval(noOperationSetIntervalTime)
+        quit()
+        $.closeModal();
+        return
+      }
+      index--
+      $('.operate-time-exit').text(`退出(${index}秒)`)
+    }, 1000)
+  }, 1000 * 20)
+}
 // 蒙版
 var canvas_bak = document.getElementById('box');
 
@@ -65,7 +95,7 @@ function doConnectDirectives() {
       } else {
         clearInterval(intervalerPing);
       }
-      
+
     }, 3000)
     errorTime = 0;
     var pings = { type: 'getVsStatus' };
@@ -98,7 +128,7 @@ function doConnectDirectives() {
   };
   wsss.onerror = function (e) {
     clearInterval(intervalerPing)
-    if(!quitBool) return 
+    if (!quitBool) return
     if (directivesTimeInterval > 7) {
       quit();
       return
@@ -428,8 +458,8 @@ var draw_graph = function (graphType) {
   //鼠标按下获取 开始xy开始画图
   // var ongoingTouches = [];
   var touchstart = function (e) {
+    if(isFiringNoOperationSetTimeout) noOperationSetTimeout()
     // console.log('🚀 ~ file: WXdraw.js ~ line 244 ~ touchstart ~ e', e);
-
     if (!isControl) {
       return;
     }
@@ -470,6 +500,7 @@ var draw_graph = function (graphType) {
     if (!isControl) {
       return;
     }
+    if(isFiringNoOperationSetTimeout) noOperationSetTimeout()
     const action = 1;
     Array.from(e.originalEvent.changedTouches).forEach(function (item, index) {
       const x = item.clientX - item.target.getBoundingClientRect().x;
@@ -557,6 +588,7 @@ var draw_graph = function (graphType) {
   // 鼠标移动
   var touchmove = function (e) {
     e.preventDefault();
+    if(isFiringNoOperationSetTimeout) noOperationSetTimeout()
     if (!isControl) {
       return;
     }
@@ -637,6 +669,7 @@ var draw_graph = function (graphType) {
 
   //鼠标离开区域以外 除了涂鸦 都清空
   var mouseout = function () {
+    if(isFiringNoOperationSetTimeout) noOperationSetTimeout()
     if (graphType != 'handwriting') {
       clearContext();
     }