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 53e2d7ccbc7f167031f17030a12d9d9b25de2f5e..576963c97e4a51d100c847e4f6c92fe9aef17ccd 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 + } } // 地图坐标系