From 938a07150c920db5a67b74b71096dacfcf75c81c Mon Sep 17 00:00:00 2001 From: Yuan <294065614@qq.com> Date: Fri, 19 Jul 2024 17:31:24 +0800 Subject: [PATCH 1/8] 1 --- sdk/demo/demo.html | 81 ++-------------------------------- sdk/src/DirectionHandler.js | 88 +++++++++---------------------------- 2 files changed, 24 insertions(+), 145 deletions(-) diff --git a/sdk/demo/demo.html b/sdk/demo/demo.html index 8aaaf45..964c5da 100644 --- a/sdk/demo/demo.html +++ b/sdk/demo/demo.html @@ -218,17 +218,6 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. .cancel-btn { border: none; } - #mobileNetworkDelay { - display: none; - position: absolute; - left: 0; - top: 0; - width: 40px; - height: 40px; - text-align: center; - color: #3AC295; - z-index: 999; - } .slider { position: relative; width: 35px; @@ -337,22 +326,6 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. d="M39.496 6.969l3.535 3.536-7.78 7.777-3.534-3.536z" /> -
-
- 时延 ms -
-
-
-
-

温馨提示

-
-
-

-
- -

温馨提示

@@ -366,7 +339,6 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd.
-
@@ -384,12 +356,6 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd.
-
-
时延
-
-
-
-
全屏
@@ -435,12 +401,6 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd.
-
-
-
-
-
时延
-
@@ -580,7 +540,8 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. ...cloudPhoneParams, channelType: channelType, ticket: '256random'.padStart(256, '0'), - aes_key: '11111111111111111111111111111111', + // aes_key: '38cd1479423e42369f099661d3f61ee6', + aes_key: 'bdbf24c2c2db43c58b18e4232ada9026', auth_ts: 'test_auth_ts', _debug: true, auto_rotate: true, @@ -620,11 +581,8 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. cloudapp.on("netStateChange", function (event, data) { let delayElement = null; if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) { - delayElement = document.getElementById('mobileNetworkDelay'); } else { - delayElement = document.getElementById('pcNetworkDelay'); } - delayElement.innerHTML = data.delay; }); // 时延开关 @@ -710,10 +668,6 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. showTrustModal(targetStr); }, error => { const errorMsg = error && JSON.parse(error).errorMsg; - const modalEle = document.getElementById('messageModal'); - const msgEle = document.getElementById('msgContent'); - msgEle.innerText = errorMsg; - modalEle.style.display = 'block'; }); } @@ -723,15 +677,7 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. let sliderBtnEle = null; let sliderBtnBg = null; if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) { - networkInfoElement = document.getElementById('mobileNetworkDelay'); - sliderEle = document.getElementById('networkSlider'); - sliderBtnEle = document.getElementById('networkSliderBtn'); - sliderBtnBg = '#fff'; } else { - networkInfoElement = document.getElementById('pcNetworkContent'); - sliderEle = document.getElementById('pcNetworkSlider'); - sliderBtnEle = document.getElementById('pcNetworkSliderBtn'); - sliderBtnBg = '#eee'; } sliderEle.addEventListener('click', () => { @@ -740,12 +686,10 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. sliderBtnEle.style.left = '15px'; sliderEle.style.backgroundColor = '#a17c7f'; sliderBtnEle.style.backgroundColor = '#85090c'; - networkInfoElement.style.display = 'inline-block'; } else { sliderBtnEle.style.left = '0px'; sliderEle.style.backgroundColor = '#ccc'; sliderBtnEle.style.backgroundColor = sliderBtnBg; - networkInfoElement.style.display = 'none'; } }); } @@ -769,8 +713,6 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. function exit() { cloudapp.exit(); - var networkInfoElement = document.getElementById('mobileNetworkDelay'); - networkInfoElement.hidden = true; let isAppUse = false; try { @@ -862,26 +804,9 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. return decodeURIComponent(encodedStr); } - function showAlertModal(data) { - const modalEle = document.getElementById('messageModal'); - const msgEle = document.getElementById('msgContent'); - const startSuccessState = 512; - // 连接成功需要关闭已显示的弹框 - if (data.state === startSuccessState) { - if(modalEle.style.display === 'block') { - modalEle.style.display = 'none'; - return; - } - } - if (data.tip) { - msgEle.innerHTML = data.tip; - modalEle.style.display = 'block'; - } - } + function showAlertModal(data) {} function closeModal() { - const modalEle = document.getElementById('messageModal'); - modalEle.style.display = 'none'; if (cloudapp) { exit(); } diff --git a/sdk/src/DirectionHandler.js b/sdk/src/DirectionHandler.js index 324c5e9..3c6bd7e 100644 --- a/sdk/src/DirectionHandler.js +++ b/sdk/src/DirectionHandler.js @@ -45,8 +45,14 @@ class DirectionHandler { this.touchHandler = this.options.touchHandler; this.containerEle = document.getElementById(this.options.containerId); - this.netWorkInfo = document.getElementById('network-info'); - this.messageModal = document.getElementById('messageModal'); + this.netWorkInfo = { + clientHeight: 0, + clientWidth: 0 + }; + this.messageModal ={ + width: '0px', + height: '0px' + }; this.exitModal = document.getElementById('exitModal'); this.buttonModal = document.getElementById('buttonModal'); this.ctrlEle = document.getElementById('controlBtn'); @@ -143,25 +149,7 @@ class DirectionHandler { transform: rotate(${positionParams.transformAngle}deg); transform-origin: left top; `; - this.messageModal.style.cssText = transformCssText; this.exitModal.style.cssText = transformCssText; - this.netWorkInfo.style.cssText = ` - transform-origin: left; - -webkit-transform: rotate(${positionParams.transformAngle}deg); - -moz-transform: rotate(${positionParams.transformAngle}deg); - -ms-transform: rotate(${positionParams.transformAngle}deg); - -o-transform: rotate(${positionParams.transformAngle}deg); - transform: rotate(${positionParams.transformAngle}deg); - pointer-events: none; - position: absolute; - left: ${positionParams.netWorkInfoLeft}px; - top: ${positionParams.netWorkInfoTop}px; - height: 40px; - line-height: 40px; - text-align: center; - width: ${positionParams.netWorkInfoWidth}px; - color: #3AC295; - `; this.buttonModal.style.cssText = ` -webkit-transform: rotate(${positionParams.transformAngle}deg); -moz-transform: rotate(${positionParams.transformAngle}deg); @@ -204,18 +192,7 @@ class DirectionHandler { // 设备不旋转,流不旋转 portraitAndportrait(ctrlEleLeft, ctrlEleTop) { - this.messageModal.style.cssText = normalCssText; this.exitModal.style.cssText = normalCssText; - this.netWorkInfo.style.cssText = ` - pointer-events: none; - position: absolute; - top: 0px; - height: 40px; - line-height: 40px; - text-align: center; - width: 100%; - color: #3AC295; - `; this.buttonModal.style.cssText = ` display: none; width: 255px; @@ -239,10 +216,10 @@ class DirectionHandler { const transformAngle = DOM_ORIENTATION_ANGLES[orientationStr]; const netWorkInfoLeft = (this.containerEle.clientWidth - this.netWorkInfo.clientWidth)/2 + this.netWorkInfo.clientWidth; const netWorkInfoTop = this.containerEle.clientHeight - this.netWorkInfo.clientHeight; - const commonLeft = (this.containerEle.clientWidth - this.displayBox.width)/2 + Number(window.getComputedStyle(this.messageModal).width.split('px')[0]) + (this.displayBox.width - Number(window.getComputedStyle(this.messageModal).width.split('px')[0]))/2; - const commonTop =this.containerEle.clientHeight/2 + Number(window.getComputedStyle(this.messageModal).height.split('px')[0])/2; + const commonLeft = (this.containerEle.clientWidth - this.displayBox.width)/2 + Number(this.messageModal.width.split('px')[0]) + (this.displayBox.width - Number(this.messageModal.width.split('px')[0]))/2; + const commonTop =this.containerEle.clientHeight/2 + Number(this.messageModal.height.split('px')[0])/2; const buttonModalLeft = (this.containerEle.clientWidth - this.displayBox.width)/2 + Number(window.getComputedStyle(this.buttonModal).width.split('px')[0]) + (this.displayBox.width - Number(window.getComputedStyle(this.buttonModal).width.split('px')[0]))/2; - const buttonModalTop = this.containerEle.clientHeight/2 + Number(window.getComputedStyle(this.messageModal).height.split('px')[0])/2; + const buttonModalTop = this.containerEle.clientHeight/2 + Number(this.messageModal.height.split('px')[0])/2; const ctrlEleTop = this.containerEle.clientHeight - this.netWorkInfo.clientHeight * 2.5; const ctrlEleLeft = (this.containerEle.clientWidth - this.displayBox.width)/2 + this.displayBox.width - this.ctrlEle.clientWidth * 1.5; const netWorkInfoWidth = this.containerEle.clientWidth; @@ -272,8 +249,8 @@ class DirectionHandler { const transformAngle = DOM_ORIENTATION_ANGLES[orientationStr]; const netWorkInfoLeft = this.containerEle.clientWidth - this.netWorkInfo.clientHeight; const netWorkInfoTop = -this.netWorkInfo.clientHeight/2; - const commonLeft = this.containerEle.clientWidth - Number(window.getComputedStyle(this.messageModal).height.split('px')[0]); - const commonTop = (this.containerEle.clientHeight - Number(window.getComputedStyle(this.messageModal).width.split('px')[0]))/2; + const commonLeft = this.containerEle.clientWidth - Number(this.messageModal.height.split('px')[0]); + const commonTop = (this.containerEle.clientHeight - Number(this.messageModal.width.split('px')[0]))/2; const buttonModalLeft = this.containerEle.clientWidth - Number(window.getComputedStyle(this.buttonModal).height.split('px')[0]); const buttonModalTop = (this.containerEle.clientHeight - Number(window.getComputedStyle(this.buttonModal).width.split('px')[0]))/2; const ctrlEleTop = (this.containerEle.clientHeight - this.displayBox.width)/2 + this.netWorkInfo.clientHeight; @@ -315,7 +292,7 @@ class DirectionHandler { const netWorkInfoLeft = (windowHeight - this.containerEle.clientWidth)/2 + this.containerEle.clientWidth - this.netWorkInfo.clientHeight; const netWorkInfoTop = -this.netWorkInfo.clientHeight/2; const commonLeft = this.containerEle.clientWidth; - const commonTop = (this.containerEle.clientHeight - Number(window.getComputedStyle(this.messageModal).width.split('px')[0]))/2; + const commonTop = (this.containerEle.clientHeight - Number(this.messageModal.width.split('px')[0]))/2; const buttonModalLeft = this.containerEle.clientWidth; const buttonModalTop = (this.containerEle.clientHeight - Number(window.getComputedStyle(this.buttonModal).width.split('px')[0]))/2; const ctrlEleTop = this.ctrlEle.clientHeight; @@ -355,8 +332,8 @@ class DirectionHandler { const transformAngle = DOM_ORIENTATION_ANGLES[orientationStr]; const netWorkInfoLeft = this.netWorkInfo.clientHeight; const netWorkInfoTop = this.containerEle.clientHeight - this.netWorkInfo.clientHeight/2; - const commonLeft = (this.displayBox.height - Number(window.getComputedStyle(this.messageModal).height.split('px')[0]))/2; - const commonTop = `${(this.containerEle.clientHeight - Number(window.getComputedStyle(this.messageModal).width.split('px')[0]))/2 + Number(window.getComputedStyle(this.messageModal).width.split('px')[0])}`; + const commonLeft = (this.displayBox.height - Number(this.messageModal.height.split('px')[0]))/2; + const commonTop = `${(this.containerEle.clientHeight - Number(this.messageModal.width.split('px')[0]))/2 + Number(this.messageModal.width.split('px')[0])}`; const buttonModalTop = `${(this.containerEle.clientHeight - Number(window.getComputedStyle(this.buttonModal).width.split('px')[0]))/2 + Number(window.getComputedStyle(this.buttonModal).width.split('px')[0])}`; const buttonModalLeft = (this.displayBox.height - Number(window.getComputedStyle(this.buttonModal).height.split('px')[0]))/2; const ctrlEleTop = (this.containerEle.clientHeight - this.displayBox.width)/2 + this.displayBox.width - this.ctrlEle.clientHeight; @@ -392,7 +369,7 @@ class DirectionHandler { const netWorkInfoTop = this.containerEle.clientHeight - this.netWorkInfo.clientHeight/2; const buttonModalTop = `${(this.containerEle.clientHeight - Number(window.getComputedStyle(this.buttonModal).width.split('px')[0]))/2 + Number(window.getComputedStyle(this.buttonModal).width.split('px')[0])}`; const buttonModalLeft = 0; - const commonTop = `${(this.containerEle.clientHeight - Number(window.getComputedStyle(this.messageModal).width.split('px')[0]))/2 + Number(window.getComputedStyle(this.messageModal).width.split('px')[0])}`; + const commonTop = `${(this.containerEle.clientHeight - Number(this.messageModal.width.split('px')[0]))/2 + Number(this.messageModal.width.split('px')[0])}`; const commonLeft = 0; const ctrlEleTop = this.containerEle.clientHeight - this.ctrlEle.clientHeight; const ctrlEleLeft =-((windowHeight - this.containerEle.clientWidth)/2 - this.netWorkInfo.clientHeight * 2); @@ -439,19 +416,7 @@ class DirectionHandler { // 设备横屏,流旋转0 landscapeAndPortrait() { const clientWidth = document.documentElement.clientWidth; - this.messageModal.style.cssText = normalCssText; this.exitModal.style.cssText = normalCssText; - this.netWorkInfo.style.cssText = ` - pointer-events: none; - position: absolute; - top: 0px; - left: ${-(document.documentElement.clientWidth - this.containerEle.clientWidth)/2}px; - height: 40px; - line-height: 40px; - text-align: center; - width: ${document.documentElement.clientWidth}px; - color: #3AC295; - `; this.buttonModal.style.cssText = ` display: none; width: 255px; @@ -489,8 +454,8 @@ class DirectionHandler { const netWorkInfoTop = -this.netWorkInfo.clientHeight/2; const ctrlEleTop = this.ctrlEle.clientHeight; const ctrlEleLeft = (windowHeight - this.containerEle.clientWidth)/2 + this.containerEle.clientWidth - this.netWorkInfo.clientHeight * 2.5; - const commonLeft = (this.containerEle.clientWidth - Number(window.getComputedStyle(this.messageModal).height.split('px')[0]))/2 + Number(window.getComputedStyle(this.messageModal).height.split('px')[0]); - const commonTop = (this.containerEle.clientHeight - Number(window.getComputedStyle(this.messageModal).width.split('px')[0]))/2; + const commonLeft = (this.containerEle.clientWidth - Number(this.messageModal.height.split('px')[0]))/2 + Number(this.messageModal.height.split('px')[0]); + const commonTop = (this.containerEle.clientHeight - Number(this.messageModal.width.split('px')[0]))/2; const buttonModalTop = (this.containerEle.clientHeight - Number(window.getComputedStyle(this.buttonModal).width.split('px')[0]))/2; const buttonModalLeft = (this.containerEle.clientWidth - Number(window.getComputedStyle(this.buttonModal).height.split('px')[0]))/2 + Number(window.getComputedStyle(this.buttonModal).height.split('px')[0]); const netWorkInfoWidth = this.containerEle.clientHeight; @@ -526,8 +491,8 @@ class DirectionHandler { const netWorkInfoTop = this.containerEle.clientHeight - this.netWorkInfo.clientHeight/2; const ctrlEleTop = this.containerEle.clientHeight - this.ctrlEle.clientHeight; const ctrlEleLeft =-((windowHeight - this.containerEle.clientWidth)/2 - this.ctrlEle.clientWidth); - const commonLeft = (this.containerEle.clientWidth - Number(window.getComputedStyle(this.messageModal).height.split('px')[0]))/2; - const commonTop = (this.containerEle.clientHeight - Number(window.getComputedStyle(this.messageModal).width.split('px')[0]))/2 + Number(window.getComputedStyle(this.messageModal).width.split('px')[0]); + const commonLeft = (this.containerEle.clientWidth - Number(this.messageModal.height.split('px')[0]))/2; + const commonTop = (this.containerEle.clientHeight - Number(this.messageModal.width.split('px')[0]))/2 + Number(this.messageModal.width.split('px')[0]); const buttonModalTop = (this.containerEle.clientHeight - Number(window.getComputedStyle(this.buttonModal).width.split('px')[0]))/2 + Number(window.getComputedStyle(this.buttonModal).width.split('px')[0]); const buttonModalLeft = (this.containerEle.clientWidth - Number(window.getComputedStyle(this.buttonModal).height.split('px')[0]))/2; const netWorkInfoWidth = this.containerEle.clientHeight; @@ -591,18 +556,7 @@ class DirectionHandler { } cancelTransform() { - this.messageModal.style.cssText = normalCssText; this.exitModal.style.cssText = normalCssText; - this.netWorkInfo.style.cssText = ` - pointer-events: none; - position: absolute; - top: 0px; - height: 40px; - line-height: 40px; - text-align: center; - width: 100%; - color: #3AC295; - `; this.buttonModal.style.cssText = ` display: none; width: 255px; -- Gitee From ccd62215a4fd49afa21782f2c0529855a49f8110 Mon Sep 17 00:00:00 2001 From: Yuan <294065614@qq.com> Date: Fri, 19 Jul 2024 17:47:04 +0800 Subject: [PATCH 2/8] 1 --- sdk/demo/demo.html | 99 -------------------------------- sdk/src/AppController.js | 9 --- sdk/src/DirectionHandler.js | 109 +++++++----------------------------- 3 files changed, 20 insertions(+), 197 deletions(-) diff --git a/sdk/demo/demo.html b/sdk/demo/demo.html index 964c5da..5b83df9 100644 --- a/sdk/demo/demo.html +++ b/sdk/demo/demo.html @@ -326,50 +326,6 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. d="M39.496 6.969l3.535 3.536-7.78 7.777-3.534-3.536z" />
-
-
-

温馨提示

-
-
-

确定退出吗?

-
- -
-
-
-
-
-
- - -
-
- - -
-
- - -
-
-
-
-
全屏
-
-
-
-
-
退出云手机
-
-
- - - -
-
@@ -386,30 +342,6 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd.
-
-
-
-
- - -
-
- - -
-
- - -
-
-
-
- - - - -
-