Selaa lähdekoodia

Merge branch 'feature/兼容横屏分辨率切换' of Software/android-cloud-H5 into develop

zengzhixiang 2 vuotta sitten
vanhempi
commit
02fd871e75

+ 1 - 0
static/screenAndroid/WXdraw.js

@@ -123,6 +123,7 @@ function doConnectDirectives() {
         if (result.data.code === 'phoneSizeChange') {
           console.log(result.data);
           window.currentPhoneSize = {
+          id: result.data.id,
             width: result.data.width,
             height: result.data.height,
             pid: result.data.pid,

+ 37 - 6
static/screenAndroid/WXtrialInterface.html

@@ -764,11 +764,30 @@
               //横屏处理
               resolving = 0;
             }
-            wsss.send(
-              JSON.stringify({
-                type: 'getPhoneSize',
-              }),
-            );
+            window.phoneSizeList = window.phoneSizeListBack.map(function (
+              item,
+            ) {
+              return resolving
+                ? item
+                : Object.assign({}, item, {
+                    width: item.height,
+                    height: item.width,
+                  });
+            });
+
+            // wsss.send(
+            //   JSON.stringify({
+            //     type: 'getPhoneSize',
+            //   }),
+            // );
+            // 横竖屏变更时获取分辨率要延迟,不然会获取到变更前的分辨率
+            setTimeout(function () {
+              wsss.send(
+                JSON.stringify({
+                  type: 'getPhoneSize',
+                }),
+              );
+            }, 500);
           }
           if (input[23] == 0x0b) {
             //多端登录处理, 数据从索引24开始取, input 是接收到的原始数据
@@ -1635,6 +1654,7 @@
         const phoneSizeListItemsHtml = templatePhoneSizeItem({
           list: window.phoneSizeList,
           active: window.activePhoneSize,
+          resolving,
         });
         $('#phone-size-list').html(phoneSizeListItemsHtml);
       }
@@ -1686,10 +1706,12 @@
 
       getPhoneSizeList().then(function (phoneSizeList) {
         window.phoneSizeList = phoneSizeList;
+        window.phoneSizeListBack = phoneSizeList; // 备份下数据,用户横竖切换时。
         const currentPhoneSize = window.phoneSizeList.find(function (v) {
           return (
             v.width === window.currentPhoneSize.width &&
-            v.height === window.currentPhoneSize.height
+            v.height === window.currentPhoneSize.height &&
+            v.dpi === window.currentPhoneSize.dpi
           );
         });
         window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
@@ -1703,6 +1725,13 @@
       //   centeredSlides: true,
       // });
       function setPhoneSize(config) {
+        config = resolving
+          ? config
+          : Object.assign({}, config, {
+              width: config.height,
+              height: config.width,
+            });
+        // 修改云机分辨率
         wsss.send(
           JSON.stringify({
             type: 'setPhoneSize',
@@ -1714,6 +1743,7 @@
             },
           }),
         );
+        // 通知其他在线端
         wsss.send(
           JSON.stringify({
             type: 'forwardMsg',
@@ -1727,6 +1757,7 @@
             },
           }),
         );
+        // 上报分辨率
         $.ajax({
           url:
             baseUrl +

+ 1 - 1
static/screenIos/WXdraw.js

@@ -178,7 +178,7 @@ function doConnectDirectives() {
       return;
     }
     if (result.type === 'getPhoneSize') {
-      // console.log(result);
+      console.log(result);
       const data = window.phoneSizeList.find(function (v) {
         return (
           v.width === result.data.width &&

+ 34 - 6
static/screenIos/WXtrialInterface.html

@@ -1072,11 +1072,30 @@
                 resolving = 0;
                 // $('#playCanvas').removeClass('vertical').addClass('horizontal');
               }
-              wsss.send(
-                JSON.stringify({
-                  type: 'getPhoneSize',
-                }),
-              );
+              window.phoneSizeList = window.phoneSizeListBack.map(function (
+                item,
+              ) {
+                return resolving
+                  ? item
+                  : Object.assign({}, item, {
+                      width: item.height,
+                      height: item.width,
+                    });
+              });
+
+              // wsss.send(
+              //   JSON.stringify({
+              //     type: 'getPhoneSize',
+              //   }),
+              // );
+              // 横竖屏变更时获取分辨率要延迟,不然会获取到变更前的分辨率
+              setTimeout(function () {
+                wsss.send(
+                  JSON.stringify({
+                    type: 'getPhoneSize',
+                  }),
+                );
+              }, 500);
             }
             if (input[23] == 0x0b) {
               console.log('多端登陆');
@@ -1421,6 +1440,7 @@
         const phoneSizeListItemsHtml = templatePhoneSizeItem({
           list: window.phoneSizeList,
           active: window.activePhoneSize,
+          resolving,
         });
         $('#phone-size-list').html(phoneSizeListItemsHtml);
       }
@@ -1474,10 +1494,12 @@
 
       getPhoneSizeList().then(function (phoneSizeList) {
         window.phoneSizeList = phoneSizeList;
+        window.phoneSizeListBack = phoneSizeList; // 备份下数据,用户横竖切换时。
         const currentPhoneSize = window.phoneSizeList.find(function (v) {
           return (
             v.width === window.currentPhoneSize.width &&
-            v.height === window.currentPhoneSize.height
+            v.height === window.currentPhoneSize.height &&
+            v.dpi === window.currentPhoneSize.dpi
           );
         });
         window.currentPhoneSize = currentPhoneSize || window.currentPhoneSize;
@@ -1491,6 +1513,12 @@
       //   centeredSlides: true,
       // });
       function setPhoneSize(config) {
+        config = resolving
+          ? config
+          : Object.assign({}, config, {
+              width: config.height,
+              height: config.width,
+            });
         // 修改云机分辨率
         wsss.send(
           JSON.stringify({