Ver código fonte

Merge branch 'develop' of Software/android-cloud-H5 into release/v5.4.0

zengzhixiang 2 anos atrás
pai
commit
21ae4ca5d4

+ 60 - 28
Jenkinsfile

@@ -10,6 +10,10 @@ pipeline {
   options{
     disableConcurrentBuilds()
   }
+  parameters {
+    booleanParam(name: 'auto_run_docker_nginx_build_job', defaultValue: false, description: '自动运行docker构建任务')
+    booleanParam(name: 'auto_run_docker_nginx_pull_job', defaultValue: false, description: '自动运行docker发布任务')
+  }
 
   triggers {
     GenericTrigger(
@@ -33,6 +37,23 @@ pipeline {
     // 实现任务的具体流程
     stage('初始化构建环境') {
       steps {
+        echo "env.ref: ${env.ref}"
+        script {
+          if (env.ref) {
+            echo "任务来源git Webhooks开启自动构建并发布docker"
+            env.auto_run_docker_nginx_build_job = "true"
+            env.auto_run_docker_nginx_pull_job = "true"
+          }
+        }
+        echo "自动运行docker构建任务: ${env.auto_run_docker_nginx_build_job}"
+        echo "自动运行docker发布任务: ${env.auto_run_docker_nginx_pull_job}"
+
+        // XXX: 此处需注意类型
+        // params.auto_run_docker_nginx_build_job === false
+        // env.auto_run_docker_nginx_build_job === "false"
+
+
+        // echo "params.auto_run_docker_nginx_pull_job: ${params.auto_run_docker_nginx_pull_job}"
         // echo 'env.BRANCH_NAME: ' + env.BRANCH_NAME
         // echo 'env.BUILD_NUMBER: ' + env.BUILD_NUMBER
         // echo 'env.BUILD_ID: ' + env.BUILD_ID
@@ -75,53 +96,64 @@ pipeline {
     }
     stage('构建docker镜像') {
       when {
-        anyOf {
-          branch 'develop'
-          // branch 'uat'
-          branch 'master'
-          expression { BRANCH_NAME ==~ /^(release\/.+)$/ }
+        allOf {
+          expression { env.auto_run_docker_nginx_build_job == "true" }
+          anyOf {
+            branch "develop"
+            // branch 'uat'
+            // branch "master"
+            // branch "release/*"
+            // expression { BRANCH_NAME ==~ /^(release\/.+)$/ }
+          }
         }
       }
       environment {
-        BUILD_DOCKER_JOB = 'cloud_build_docker_nginx_powerful_test'
+        BUILD_DOCKER_JOB = "cloud_build_docker_nginx/test"
       }
       steps {
-        // echo '开始构建docker镜像'
+        echo '开始构建docker镜像'
         script {
-          if (env.BRANCH_NAME == 'master') {
-            BUILD_DOCKER_JOB = 'cloud_build_docker_nginx_prod'
+          if (env.BRANCH_NAME == "master") {
+            env.BUILD_DOCKER_JOB = "cloud_build_docker_nginx/prod"
           } else if (env.BRANCH_NAME ==~ /^(release\/.+)$/) {
-            BUILD_DOCKER_JOB = 'cloud_build_docker_nginx_pre'
+            env.BUILD_DOCKER_JOB = "cloud_build_docker_nginx/uat"
           } else {
-            BUILD_DOCKER_JOB = 'cloud_build_docker_nginx_powerful_test'
+            env.BUILD_DOCKER_JOB = "cloud_build_docker_nginx/test"
           }
         }
-        build job: BUILD_DOCKER_JOB, parameters: [string(name: 'version', value: env.BUILD_TAG), extendedChoice(name: 'service', value: 'manage_H5')]
+        echo "build job: ${env.BUILD_DOCKER_JOB}"
+        build job: env.BUILD_DOCKER_JOB, parameters: [string(name: 'version', value: env.BUILD_TAG), extendedChoice(name: 'service', value: 'manage_H5'),  booleanParam(name: 'auto_run_docker_nginx_pull_job', value: false), string(name: 'manage_H5_workspace', value: env.WORKSPACE)]
       }
     }
     stage('发布docker镜像') {
       when {
-        anyOf {
-          // branch 'master'
-          // branch 'uat'
-          branch 'develop'
+        allOf {
+          expression { env.auto_run_docker_nginx_build_job == "true" }
+          expression { env.auto_run_docker_nginx_pull_job == "true" }
+          anyOf {
+            branch 'develop'
+            // branch 'uat'
+            // branch 'master'
+            // expression { BRANCH_NAME ==~ /^(release\/.+)$/ }
+          }
         }
       }
       environment {
-        PUBLISH_DOCKER_JOB = 'cloud_publish_docker_powerful_test'
+        PULL_DOCKER_JOB = 'cloud_publish_docker_powerful_test'
       }
       steps {
-        // echo '开始构建docker镜像'
-        // script {
-        //   if ( env.BRANCH_NAME == 'master' ) {
-        //     PUBLISH_DOCKER_JOB = 'cloud_publish_docker_powerful_test'
-        //   } else if ( env.BRANCH_NAME == 'uat' ) {
-        //     PUBLISH_DOCKER_JOB = 'cloud_publish_docker_powerful_test'
-        //   } else {
-        //     PUBLISH_DOCKER_JOB = 'cloud_publish_docker_powerful_test'
-        //   }
-        // }
-        build job: PUBLISH_DOCKER_JOB, parameters: [extendedChoice(name: 'service', value: 'cloud-nginx'), string(name: 'version', value: env.BUILD_TAG), string(name: 'replicas', value: '3'), string(name: 'memory', value: '2G'), string(name: 'cpu', value: '2')]
+        echo '开始发布docker镜像'
+        script {
+          if ( env.BRANCH_NAME == 'master' ) {
+            // env.PULL_DOCKER_JOB = 'cloud_publish_docker_powerful_test'
+          } else if ( env.BRANCH_NAME == 'uat' ) {
+            env.PULL_DOCKER_JOB = 'cloud_publish_docker_pre'
+          } else {
+            env.PULL_DOCKER_JOB = 'cloud_publish_docker_powerful_test'
+          }
+        }
+        echo "build job: ${env.PULL_DOCKER_JOB}"
+        build job: env.PULL_DOCKER_JOB, parameters: [extendedChoice(name: 'service', value: 'cloud-nginx'), string(name: 'version', value: env.BUILD_TAG), string(name: 'replicas', value: '3'), string(name: 'memory', value: '2G'), string(name: 'cpu', value: '2')]
       }
     }
   }

+ 2 - 2
pages/phone/_id.vue

@@ -37,12 +37,12 @@ export default {
       }/WXtrialInterface.html${qs.stringify(
         {
           userCardId,
-          username: userName,
+          username: $auth.user.username,
           token,
           rm: room,
           mealType: buyVipType,
           sourceType,
-          authPhone,
+          authPhone: authPhone ? 'huo' : 'none',
           validTime,
         },
         {

+ 52 - 1
schemes/password.js

@@ -4,7 +4,22 @@ import { LocalScheme } from '~auth/runtime';
 // const { createHash } = await import('node:crypto');
 let publicKey;
 const encrypt = new JSEncrypt();
-
+function getProp(holder, propName) {
+  if (!propName || !holder || typeof holder !== 'object') {
+    return holder;
+  }
+  if (propName in holder) {
+    return holder[propName];
+  }
+  const propParts = Array.isArray(propName)
+    ? propName
+    : (propName + '').split('.');
+  let result = holder;
+  while (propParts.length && result) {
+    result = result[propParts.shift()];
+  }
+  return result;
+}
 export default class CustomScheme extends LocalScheme {
   async login(data, { reset = true } = {}) {
     const endpoint = { data: Object.assign({}, data) };
@@ -53,6 +68,8 @@ export default class CustomScheme extends LocalScheme {
       this.options.endpoints.login,
     );
     this.updateTokens(response);
+    // localStorage.setItem('auth.username', response.data.data.username);
+
     if (!this.requestHandler.interceptor) {
       this.initializeRequestInterceptor();
     }
@@ -61,4 +78,38 @@ 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);
+
+  //       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);
+  //     });
+  // }
 }

+ 121 - 55
static/screenAndroid/WXdraw.js

@@ -21,8 +21,8 @@ url = url.split('/');
 
 var parameters = GetRequest();
 var videoWidth, videoHeight;
-var isControl = true; // 是否是观看模式
-changIsControl(true);
+var isControl = false; // 是否是观看模式
+changIsControl(false);
 var isAuth = parameters['authPhone']; // 是否是获取的云手机
 
 var wsss,
@@ -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) {
@@ -91,11 +104,63 @@ function doConnectDirectives() {
       }
       return;
     }
+    if (result.type === 'forwardMsgRep') {
+      // 当前云机无其他终端在线,获得控制权
+      changIsControl(true);
+    }
     if (result.type === 'forwardMsg') {
+      /**
+       * @type {boolean} isControl 当前是否拥有控制权,初始化时为false
+       * @type {string} isAuth 当前云机类型 - huo: 获取的云机,none: 自己的云机
+       * @type {string} username 当前登录的双子星账号username
+       */
       switch (String(result.data.code)) {
         case '3000': {
+          // 被询问控制
+          if (isControl) {
+            // 回复有控制
+            wsss.send(
+              JSON.stringify({
+                type: 'forwardMsg',
+                data: {
+                  code: '4000',
+                  username,
+                  desc: '有控制', // 可选
+                },
+              }),
+            );
+            return;
+          }
+          // 回复有观看
+          wsss.send(
+            JSON.stringify({
+              type: 'forwardMsg',
+              data: {
+                code: '4100',
+                username,
+                desc: '有观看', // 可选
+              },
+            }),
+          );
+          return;
+        }
+        case '4100': {
+          // 收到观看回复
+          changIsControl(true);
+          return;
         }
         case '4000': {
+          // 收到控制权回复
+
+          // 同账号,共同控制
+          if (result.data.username === username) {
+            changIsControl(true);
+            return;
+          }
+
+          // 不同账号
+
+          // 当前是获取方
           if (isAuth === 'huo') {
             $.confirm(
               '授权方已收回控制权,您进入观看屏幕模式',
@@ -111,51 +176,48 @@ function doConnectDirectives() {
             );
             return;
           }
-          $.confirm(
-            '当前云手机正在授控,是否请求获取云手机控制权?',
-            function () {
-              //点击确认后的回调函数
-              var ping = {
-                type: 'forwardMsg',
-                data: {
-                  code: '5000',
-                  desc: '控制权限收回', // 可选
-                },
-              };
-              wsss.send(JSON.stringify(ping));
-              changIsControl(true);
-            },
-            function () {
-              //点击取消后的回调函数
-              changIsControl(false);
-            },
-          );
+          if (!isControl) {
+            // 当前是授权方切没有控制权
+            $.confirm(
+              '当前云手机正在授控,是否请求获取云手机控制权?',
+              function () {
+                //点击确认后的回调函数
+                wsss.send(
+                  JSON.stringify({
+                    type: 'forwardMsg',
+                    data: {
+                      code: '5000',
+                      desc: '控制权限收回', // 可选
+                    },
+                  }),
+                );
+                changIsControl(true);
+              },
+              function () {
+                //点击取消后的回调函数
+                changIsControl(false);
+              },
+            );
+            return;
+          }
           return;
         }
         case '5000': {
-          console.log(result);
-          $.confirm(
-            '授权方已收回控制权,您进入观看屏幕模式',
-            function () {
-              //点击确认后的回调函数
-              changIsControl(false);
-            },
-            function () {
-              changIsControl(false);
-
-              //点击取消后的回调函数
-              quit();
-            },
-          );
-          return;
-        }
-        case 'phoneSizeChange': {
-          window.currentPhoneSize = {
-            id: result.data.id,
-            width: result.data.width,
-            height: result.data.height,
-            pid: result.data.pid,
-          };
+          if (isControl && isAuth === 'huo') {
+            $.confirm(
+              '授权方已收回控制权,您进入观看屏幕模式',
+              function () {
+                //点击确认后的回调函数
+                changIsControl(false);
+              },
+              function () {
+                changIsControl(false);
+                //点击取消后的回调函数
+                quit();
+              },
+            );
+            return;
+          }
           return;
         }
         default: {
@@ -193,20 +255,24 @@ function doConnectDirectives() {
       });
       return;
     }
-    if (result.type === 'getPhoneSize') {
+    if (result.type === 'getPhoneSize' || result.type === 'setPhoneSize') {
       // console.log(result);
       const data = window.phoneSizeList.find(function (v) {
         return (
-          v.width === result.data[resolving ? 'width' : 'height'] &&
-          v.height === result.data[resolving ? 'height' : 'width'] &&
-          v.pid === result.data.pid
+          v.width === Math.min(result.data.width, result.data.height) &&
+          v.height === Math.max(result.data.width, result.data.height) &&
+          v.dpi === result.data.dpi
         );
       });
       window.currentPhoneSize = data || {
-        width: result.data[resolving ? 'width' : 'height'],
-        height: result.data[resolving ? 'height' : 'width'],
-        pid: result.data.pid,
+        width: Math.min(result.data.width, result.data.height),
+        height: Math.max(result.data.width, result.data.height),
+        dpi: result.data.dpi,
       };
+
+      if (result.type === 'setPhoneSize') {
+        lastSetPhone = Date.now();
+      }
       return;
     }
   };

+ 63 - 27
static/screenAndroid/WXtrialInterface.html

@@ -42,7 +42,10 @@
       rel="stylesheet"
       href="https://cdn.bootcss.com/jquery-weui/1.2.1/css/jquery-weui.min.css"
     />
+    <!-- <link rel="stylesheet" href="../static/lib/swiper/swiper-bundle.min.css" />
+    <script src="../static/lib/swiper/swiper-bundle.js"></script> -->
     <script src="../static/lib/doT-1.1.3/doT.min.js"></script>
+    <script src="../static/lib/qs.js"></script>
   </head>
 
   <body class="scroll h-player" style="overscroll-behavior: contain">
@@ -67,7 +70,7 @@
       </div>
       <div class="slide-wrapper-content">
         {{~ it :item:index }}
-        <div class="slide-wrapper">
+        <div class="slide-wrapper" data-id="{{= item.id}}">
           <div class="slide-scroll animate-slide-start">
             <div
               class="slide-content"
@@ -268,8 +271,9 @@
 
       var parameters = GetRequest();
       var token = parameters['token'];
-      var userCardId = parameters['userCardId'];
       var mealType = parameters['mealType'];
+      var userCardId = parameters['userCardId'];
+      var username = parameters['username'];
       var videoTimer = null,
         videoTime = 0,
         adType = 0,
@@ -507,7 +511,9 @@
                   quit();
                 }, 3000);
               }
-            } else if (res.status === 5200) {
+              return;
+            }
+            if (res.status === 5200) {
               if (timeInterval > 7) {
                 $.toast('网络异常,请稍后重试', 'text');
                 setTimeout(() => {
@@ -521,13 +527,20 @@
                 connect(type);
                 timeInterval += 1;
               }, 3000);
-            } else {
-              $.toast('画面异常,请重新进入', 'text');
+              return;
+            }
+            if (res.status === 5220) {
+              $.toast('云手机正在一键修复中', 'text');
               setTimeout(() => {
-                clearInterval(intervaler);
                 quit();
               }, 3000);
+              return;
             }
+            $.toast('画面异常,请重新进入', 'text');
+            setTimeout(() => {
+              clearInterval(intervaler);
+              quit();
+            }, 3000);
           },
         });
       }
@@ -955,14 +968,24 @@
       }
       // 清空剪贴板
       function handleClear() {
-        var ids = '';
-        cutList.forEach(function (item) {
-          ids += 'ids=' + item.id + '&';
-        });
-        ids = ids.substring(0, ids.lastIndexOf('&'));
+        // var ids = '';
+        // cutList.forEach(function (item) {
+        //   ids += 'ids=' + item.id + '&';
+        // });
+
+        // ids = ids.substring(0, ids.lastIndexOf('&'));
+
         $.confirm('确定清空剪贴板?', function () {
           $.ajax({
-            url: baseUrl + '/api/public/v5/shear/content?' + ids,
+            url:
+              baseUrl +
+              '/api/public/v5/shear/content' +
+              Qs.stringify(
+                {
+                  ids: Array.from($('.slide-wrapper')).map((v) => v.dataset.id),
+                },
+                { arrayFormat: 'repeat', addQueryPrefix: true },
+              ),
             headers: {
               Authorization: token,
             },
@@ -1772,7 +1795,16 @@
       //   loop: false,
       //   centeredSlides: true,
       // });
+      let lastSetPhone = 0;
       function setPhoneSize(config) {
+        if (config.id === currentPhoneSize.id) {
+          return;
+        }
+
+        if (Date.now() <= lastSetPhone + 1000 * 5) {
+          throw new Error('请勿频繁操作');
+        }
+        lastSetPhone = Date.now();
         // config = Object.assign({}, config, {
         //   width: config.width,
         //   height: config.height,
@@ -1790,19 +1822,19 @@
           }),
         );
         // 通知其他在线端
-        wsss.send(
-          JSON.stringify({
-            type: 'forwardMsg',
-            data: {
-              code: 'phoneSizeChange',
-              id: config.id,
-              width: config.width,
-              height: config.height,
-              dpi: config.dpi,
-              desc: '分辨率修改', // 可选
-            },
-          }),
-        );
+        // wsss.send(
+        //   JSON.stringify({
+        //     type: 'forwardMsg',
+        //     data: {
+        //       code: 'phoneSizeChange',
+        //       id: config.id,
+        //       width: config.width,
+        //       height: config.height,
+        //       dpi: config.dpi,
+        //       desc: '分辨率修改', // 可选
+        //     },
+        //   }),
+        // );
         // 上报分辨率
         $.ajax({
           url:
@@ -1837,8 +1869,12 @@
         // setPhoneSize(data.width, data.height);
       });
       $('#set-phone-size-dialog .dialog-btn.confirm').on('click', function (e) {
-        setPhoneSize(window.activePhoneSize);
-        $('#set-phone-size-dialog').removeClass('show');
+        try {
+          setPhoneSize(window.activePhoneSize);
+          $('#set-phone-size-dialog').removeClass('show');
+        } catch (error) {
+          $.toast(error.message, 'text');
+        }
       });
     </script>
     <script type="text/javascript" src="WXdraw.js"></script>

+ 127 - 55
static/screenIos/WXdraw.js

@@ -20,8 +20,8 @@ url = url.split('/');
 var parameters = GetRequest();
 
 var videoWidth, videoHeight;
-var isControl = true; // 是否是观看模式
-changIsControl(true);
+var isControl = false; // 是否是观看模式
+changIsControl(false);
 var isAuth = parameters['authPhone']; // 是否是获取的云手机
 var wsss;
 var errorTime = 0;
@@ -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) {
@@ -100,11 +114,63 @@ function doConnectDirectives() {
       }
       return;
     }
+    if (result.type === 'forwardMsgRep') {
+      // 当前云机无其他终端在线,获得控制权
+      changIsControl(true);
+    }
     if (result.type === 'forwardMsg') {
+      /**
+       * @type {boolean} isControl 当前是否拥有控制权,初始化时为false
+       * @type {string} isAuth 当前云机类型 - huo: 获取的云机,none: 自己的云机
+       * @type {string} username 当前登录的双子星账号username
+       */
       switch (String(result.data.code)) {
         case '3000': {
+          // 被询问控制
+          if (isControl) {
+            // 回复有控制
+            wsss.send(
+              JSON.stringify({
+                type: 'forwardMsg',
+                data: {
+                  code: '4000',
+                  username,
+                  desc: '有控制', // 可选
+                },
+              }),
+            );
+            return;
+          }
+          // 回复有观看
+          wsss.send(
+            JSON.stringify({
+              type: 'forwardMsg',
+              data: {
+                code: '4100',
+                username,
+                desc: '有观看', // 可选
+              },
+            }),
+          );
+          return;
+        }
+        case '4100': {
+          // 收到观看回复
+          changIsControl(true);
+          return;
         }
         case '4000': {
+          // 收到控制权回复
+
+          // 同账号,共同控制
+          if (result.data.username === username) {
+            changIsControl(true);
+            return;
+          }
+
+          // 不同账号
+
+          // 当前是获取方
           if (isAuth === 'huo') {
             $.confirm(
               '授权方已收回控制权,您进入观看屏幕模式',
@@ -120,51 +186,53 @@ function doConnectDirectives() {
             );
             return;
           }
-          $.confirm(
-            '当前云手机正在授控,是否请求获取云手机控制权?',
-            function () {
-              //点击确认后的回调函数
-              var ping = {
-                type: 'forwardMsg',
-                data: {
-                  code: '5000',
-                  desc: '控制权限收回', // 可选
-                },
-              };
-              wsss.send(JSON.stringify(ping));
-              changIsControl(true);
-            },
-            function () {
-              //点击取消后的回调函数
-              changIsControl(false);
-            },
-          );
+          if (!isControl) {
+            // 当前是授权方切没有控制权
+            $.confirm(
+              '当前云手机正在授控,是否请求获取云手机控制权?',
+              function () {
+                //点击确认后的回调函数
+                wsss.send(
+                  JSON.stringify({
+                    type: 'forwardMsg',
+                    data: {
+                      code: '5000',
+                      desc: '控制权限收回', // 可选
+                    },
+                  }),
+                );
+                changIsControl(true);
+              },
+              function () {
+                //点击取消后的回调函数
+                changIsControl(false);
+              },
+            );
+            return;
+          }
           return;
         }
         case '5000': {
-          console.log(result);
-          $.confirm(
-            '授权方已收回控制权,您进入观看屏幕模式',
-            function () {
-              //点击确认后的回调函数
-              changIsControl(false);
-            },
-            function () {
-              changIsControl(false);
+          // if (result.data.username === username) {
+          //   changIsControl(true);
+          //   return;
+          // }
+          if (isControl && isAuth === 'huo') {
+            $.confirm(
+              '授权方已收回控制权,您进入观看屏幕模式',
+              function () {
+                //点击确认后的回调函数
+                changIsControl(false);
+              },
+              function () {
+                changIsControl(false);
+                //点击取消后的回调函数
+                quit();
+              },
+            );
+            return;
+          }
 
-              //点击取消后的回调函数
-              quit();
-            },
-          );
-          return;
-        }
-        case 'phoneSizeChange': {
-          window.currentPhoneSize = {
-            id: result.data.id,
-            width: result.data.width,
-            height: result.data.height,
-            pid: result.data.pid,
-          };
           return;
         }
         default: {
@@ -202,20 +270,24 @@ function doConnectDirectives() {
       });
       return;
     }
-    if (result.type === 'getPhoneSize') {
+    if (result.type === 'getPhoneSize' || result.type === 'setPhoneSize') {
       // console.log(result);
       const data = window.phoneSizeList.find(function (v) {
         return (
-          v.width === result.data[resolving ? 'width' : 'height'] &&
-          v.height === result.data[resolving ? 'height' : 'width'] &&
-          v.pid === result.data.pid
+          v.width === Math.min(result.data.width, result.data.height) &&
+          v.height === Math.max(result.data.width, result.data.height) &&
+          v.dpi === result.data.dpi
         );
       });
       window.currentPhoneSize = data || {
-        width: result.data[resolving ? 'width' : 'height'],
-        height: result.data[resolving ? 'height' : 'width'],
-        pid: result.data.pid,
+        width: Math.min(result.data.width, result.data.height),
+        height: Math.max(result.data.width, result.data.height),
+        dpi: result.data.dpi,
       };
+
+      if (result.type === 'setPhoneSize') {
+        lastSetPhone = Date.now();
+      }
       return;
     }
   };

+ 61 - 26
static/screenIos/WXtrialInterface.html

@@ -46,6 +46,7 @@
     <!-- <link rel="stylesheet" href="../static/lib/swiper/swiper-bundle.min.css" />
     <script src="../static/lib/swiper/swiper-bundle.js"></script> -->
     <script src="../static/lib/doT-1.1.3/doT.min.js"></script>
+    <script src="../static/lib/qs.js"></script>
   </head>
 
   <body class="scroll h-player" style="overscroll-behavior: contain">
@@ -70,7 +71,7 @@
       </div>
       <div class="slide-wrapper-content">
         {{~ it :item:index }}
-        <div class="slide-wrapper">
+        <div class="slide-wrapper" data-id="{{= item.id}}">
           <div class="slide-scroll animate-slide-start">
             <div
               class="slide-content"
@@ -342,6 +343,7 @@
       var token = parameters['token'];
       var mealType = parameters['mealType'];
       var userCardId = parameters['userCardId'];
+      var username = parameters['username'];
 
       var videoTimer = null,
         videoTime = 0,
@@ -528,7 +530,9 @@
                   quit();
                 }, 3000);
               }
-            } else if (res.status === 5200) {
+              return;
+            }
+            if (res.status === 5200) {
               if (timeInterval > 7) {
                 $.toast('网络异常,请稍后重试', 'text');
                 timerInterval = clearTimeout();
@@ -541,12 +545,19 @@
                 connect(type);
                 timeInterval += 1;
               }, 3000);
-            } else {
-              $.toast('画面异常,请重新进入', 'text');
+              return;
+            }
+            if (res.status === 5220) {
+              $.toast('云手机正在一键修复中', 'text');
               setTimeout(() => {
                 quit();
               }, 3000);
+              return;
             }
+            $.toast('画面异常,请重新进入', 'text');
+            setTimeout(() => {
+              quit();
+            }, 3000);
           },
         });
       }
@@ -674,14 +685,24 @@
       }
       // 清空剪贴板
       function handleClear() {
-        var ids = '';
-        cutList.forEach(function (item) {
-          ids += 'ids=' + item.id + '&';
-        });
-        ids = ids.substring(0, ids.lastIndexOf('&'));
+        // var ids = '';
+        // cutList.forEach(function (item) {
+        //   ids += 'ids=' + item.id + '&';
+        // });
+
+        // ids = ids.substring(0, ids.lastIndexOf('&'));
+
         $.confirm('确定清空剪贴板?', function () {
           $.ajax({
-            url: baseUrl + '/api/public/v5/shear/content?' + ids,
+            url:
+              baseUrl +
+              '/api/public/v5/shear/content' +
+              Qs.stringify(
+                {
+                  ids: Array.from($('.slide-wrapper')).map((v) => v.dataset.id),
+                },
+                { arrayFormat: 'repeat', addQueryPrefix: true },
+              ),
             headers: {
               Authorization: token,
             },
@@ -1139,7 +1160,7 @@
               //       type: 'getPhoneSize',
               //     }),
               //   );
-              // }, 1000);
+              // }, 500);
             }
             if (input[23] == 0x0b) {
               console.log('多端登陆');
@@ -1576,7 +1597,16 @@
       //   loop: false,
       //   centeredSlides: true,
       // });
+      let lastSetPhone = 0;
       function setPhoneSize(config) {
+        if (config.id === currentPhoneSize.id) {
+          return;
+        }
+
+        if (Date.now() <= lastSetPhone + 1000 * 5) {
+          throw new Error('请勿频繁操作');
+        }
+        lastSetPhone = Date.now();
         // config = Object.assign({}, config, {
         //   width: config.width,
         //   height: config.height,
@@ -1593,20 +1623,21 @@
             },
           }),
         );
+        // XXX: 去除了,改为中台发送
         // 通知其他在线端
-        wsss.send(
-          JSON.stringify({
-            type: 'forwardMsg',
-            data: {
-              code: 'phoneSizeChange',
-              id: config.id,
-              width: config.width,
-              height: config.height,
-              dpi: config.dpi,
-              desc: '分辨率修改', // 可选
-            },
-          }),
-        );
+        // wsss.send(
+        //   JSON.stringify({
+        //     type: 'forwardMsg',
+        //     data: {
+        //       code: 'phoneSizeChange',
+        //       id: config.id,
+        //       width: config.width,
+        //       height: config.height,
+        //       dpi: config.dpi,
+        //       desc: '分辨率修改', // 可选
+        //     },
+        //   }),
+        // );
         // 上报分辨率
         $.ajax({
           url:
@@ -1646,8 +1677,12 @@
         // setPhoneSize(data.width, data.height);
       });
       $('#set-phone-size-dialog .dialog-btn.confirm').on('click', function (e) {
-        setPhoneSize(window.activePhoneSize);
-        $('#set-phone-size-dialog').removeClass('show');
+        try {
+          setPhoneSize(window.activePhoneSize);
+          $('#set-phone-size-dialog').removeClass('show');
+        } catch (error) {
+          $.toast(error.message, 'text');
+        }
       });
     </script>
     <script type="text/javascript" src="WXdraw.js"></script>

Diferenças do arquivo suprimidas por serem muito extensas
+ 2054 - 0
static/static/lib/qs.js