From dbb1884c44f2d2a72497d1c9a307ddaa36e328ae Mon Sep 17 00:00:00 2001 From: handongxun Date: Thu, 12 Dec 2019 18:56:21 +0800 Subject: [PATCH] =?UTF-8?q?update:=20screenOrientation=20=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=20pages?= =?UTF-8?q?=20globalStyle=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/platforms/app-plus/index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js b/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js index 53e2d7ccb..576963c97 100644 --- a/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js +++ b/packages/webpack-uni-pages-loader/lib/platforms/app-plus/index.js @@ -18,7 +18,13 @@ const { } = require('../../util') const definePages = require('./define-pages') -const appConfigService = require('./app-config-service') +const appConfigService = require('./app-config-service') + +const wxPageOrientationMapping = { + auto: ["portrait-primary", "portrait-secondary", "landscape-primary", "landscape-secondary"], + portrait: ["portrait-primary", "portrait-secondary"], + landscape: ["landscape-primary", "landscape-secondary"] +} function parseConfig (appJson) { return { @@ -128,9 +134,14 @@ module.exports = function (pagesJson, userManifestJson) { } // 屏幕启动方向 - if (manifestJson.plus.screenOrientation) { + if (manifestJson.plus.screenOrientation) {// app平台优先使用 manifest 配置 manifestJson.screenOrientation = manifestJson.plus.screenOrientation delete manifestJson.plus.screenOrientation + } else if (appJson.window && appJson.window.pageOrientation) {// 兼容微信小程序 + const pageOrientationValue = wxPageOrientationMapping[appJson.window.pageOrientation] + if (pageOrientationValue) { + manifestJson.screenOrientation = pageOrientationValue + } } // 地图坐标系 -- GitLab