From 385abae74138f56caf5fe4c394109a8176d03453 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Wed, 10 May 2023 19:48:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20iOS16.4=E4=B9=8B=E5=89=8D=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=97=A0=E6=B3=95=E8=BF=9B=E5=85=A5=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/App.vue | 2 +- resources/assets/js/functions/common.js | 15 +++++++++++++++ resources/assets/js/store/state.js | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/resources/assets/js/App.vue b/resources/assets/js/App.vue index c8b831c94..f20bf294f 100755 --- a/resources/assets/js/App.vue +++ b/resources/assets/js/App.vue @@ -233,7 +233,7 @@ export default { windowSizeListener() { const windowWidth = $A(window).width(), windowHeight = $A(window).height(), - windowOrientation = $A.strExists(window.screen.orientation.type, 'portrait') ? 'portrait' : 'landscape' + windowOrientation = $A.screenOrientation() this.$store.state.windowTouch = "ontouchend" in document diff --git a/resources/assets/js/functions/common.js b/resources/assets/js/functions/common.js index aa0de14eb..37f88a573 100755 --- a/resources/assets/js/functions/common.js +++ b/resources/assets/js/functions/common.js @@ -547,6 +547,21 @@ const localforage = require("localforage"); }, 250); }, + /** + * 获取屏幕方向 + * @returns {string} + */ + screenOrientation() { + try { + if (typeof window.screen.orientation === "object") { + return $A.strExists(window.screen.orientation.type, 'portrait') ? 'portrait' : 'landscape' + } + } catch (e) { + // + } + return $A(window).width() > $A(window).height() ? "landscape" : "portrait" + }, + /** * 是否IOS * @returns {boolean|string} diff --git a/resources/assets/js/store/state.js b/resources/assets/js/store/state.js index b5e89919c..4f3fc766d 100644 --- a/resources/assets/js/store/state.js +++ b/resources/assets/js/store/state.js @@ -1,6 +1,6 @@ const windowWidth = $A(window).width(), windowHeight = $A(window).height(), - windowOrientation = $A.strExists(window.screen.orientation.type, 'portrait') ? 'portrait' : 'landscape' + windowOrientation = $A.screenOrientation() export default { // 客户端ID(希望不变的,除非清除浏览器缓存或者卸载应用)