解決 Hbuilder打包 Apk pad 無法橫屏
利用VUE 寫了一套H5 想著 做一個APP殼 然后把 H5 直接嵌進去 客戶要求 在pad 端 能夠操作 然后頁面風格 也需要pad 橫屏展示
下面是manifest.json 配置文件
{"@platforms": ["iPad"],"id": "__W2A__120.78.139.207",/*應用的標識,創建應用時自動生成,勿手動修改*/"name": "熱處理系統",/*應用名稱,程序桌面圖標名稱*/"version": {"name": "1.0",/*應用版本名稱*/"code": ""},"description": "",/*應用描述信息*/"icons": {"72": "icon.png"},"launch_path":"http://192.168.1.253:8080",/*應用的入口頁面,默認為根目錄下的index.html;支持網絡地址,必須以http://或https://開頭*/"developer": {"name": "",/*開發者名稱*/"email": "",/*開發者郵箱地址*/"url": ""},"permissions": {"Accelerometer": {},"Audio": {},"Messaging": {},"Cache": {"description": "管理應用緩存"},"Camera": {},"Console": {"description": "跟蹤調試輸出日志"},"Contacts": {},"Device": {},"Downloader": {},"Events": {"description": "應用擴展事件"},"File": {},"Gallery": {},"Geolocation": {},"Invocation": {},"Orientation": {},"Proximity": {},"Storage": {},"Uploader": {},"Runtime": {},"XMLHttpRequest": {},"Zip": {},"Barcode": {},"Maps": {},"Speech": {},"Webview": {},"NativeUI": {},"Navigator": {},"NativeObj": {},"OAuth": {}},"plus": {"splashscreen": {"autoclose": true,/*是否自動關閉程序啟動界面,true表示應用加載應用入口頁面后自動關閉;false則需調plus.navigator.closeSplashscreen()關閉*/"waiting": true},"statusbar": {"immersed": "supportedDevice"},"popGesture": "close",/*設置應用默認側滑返回關閉Webview窗口,"none"為無側滑返回功能,"hide"為側滑隱藏Webview窗口。參考http://ask.dcloud.net.cn/article/102*/"runmode": "normal",/*應用的首次啟動運行模式,可取liberate或normal,liberate模式在第一次啟動時將解壓應用資源(Android平臺File API才可正常訪問_www目錄)*/"signature": "Sk9JTiBVUyBtYWlsdG86aHIyMDEzQGRjbG91ZC5pbw==",/*可選,保留給應用簽名,暫不使用*/"distribute": {"apple": {"appid": "",/*iOS應用標識,蘋果開發網站申請的appid,如io.dcloud.HelloH5*/"mobileprovision": "",/*iOS應用打包配置文件*/"password": "",/*iOS應用打包個人證書導入密碼*/"p12": "",/*iOS應用打包個人證書,打包配置文件關聯的個人證書*/"devices": "universal",/*iOS應用支持的設備類型,可取值iphone/ipad/universal*/"frameworks": []},"google": {"packagename": "",/*Android應用包名,如io.dcloud.HelloH5*/"keystore": "",/*Android應用打包使用的密鑰庫文件*/"password": "",/*Android應用打包使用密鑰庫中證書的密碼*/"aliasname": "",/*Android應用打包使用密鑰庫中證書的別名*/"permissions": ["<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>","<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>","<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>","<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>","<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>","<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>","<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>","<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>","<uses-permission android:name=\"android.permission.READ_LOGS\"/>","<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>","<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>","<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>","<uses-feature android:name=\"android.hardware.camera.autofocus\"/>","<uses-feature android:name=\"android.hardware.camera\"/>","<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>","<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>","<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>","<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>","<uses-permission android:name=\"android.permission.CAMERA\"/>"]},"orientation": ["landscape-primary","landscape-secondary"],/*應用支持的方向,portrait-primary:豎屏正方向;portrait-secondary:豎屏反方向;landscape-primary:橫屏正方向;landscape-secondary:橫屏反方向*/"icons": {"ios": {"prerendered": true, /*應用圖標是否已經高亮處理,在iOS6及以下設備上有效*//*應用圖標,分辨率:512x512,用于自動生成各種尺寸程序圖標*/"iphone": {"normal": "", /*iPhone3/3GS程序圖標,分辨率:57x57*/"retina": "", /*iPhone4程序圖標,分辨率:114x114*//*iPhone4S/5/6程序圖標,分辨率:120x120*//*iPhone6 Plus程序圖標,分辨率:180x180*/"spotlight-normal": "", /*iPhone3/3GS Spotlight搜索程序圖標,分辨率:29x29*/"spotlight-retina": "", /*iPhone4 Spotlight搜索程序圖標,分辨率:58x58*//*iPhone4S/5/6 Spotlight搜索程序圖標,分辨率:80x80*/"settings-normal": "", /*iPhone4設置頁面程序圖標,分辨率:29x29*//*iPhone4S/5/6設置頁面程序圖標,分辨率:58x58*/"app@2x":"unpackage/res/icons/120x120.png","app@3x":"unpackage/res/icons/180x180.png","settings@3x":"unpackage/res/icons/87x87.png","settings@2x":"unpackage/res/icons/58x58.png","spotlight@2x":"unpackage/res/icons/80x80.png","spotlight@3x":"unpackage/res/icons/120x120.png","notification@3x":"unpackage/res/icons/60x60.png","notification@2x":"unpackage/res/icons/40x40.png"},"ipad": {"normal": "", /*iPad普通屏幕程序圖標,分辨率:72x72*/"retina": "", /*iPad高分屏程序圖標,分辨率:144x144*//*iPad iOS7程序圖標,分辨率:76x76*//*iPad iOS7高分屏程序圖標,分辨率:152x152*/"spotlight-normal": "", /*iPad Spotlight搜索程序圖標,分辨率:50x50*/"spotlight-retina": "", /*iPad高分屏Spotlight搜索程序圖標,分辨率:100x100*//*iPad iOS7 Spotlight搜索程序圖標,分辨率:40x40*//*iPad iOS7高分屏Spotlight搜索程序圖標,分辨率:80x80*//*iPad設置頁面程序圖標,分辨率:29x29*/"app":"unpackage/res/icons/76x76.png","app@2x":"unpackage/res/icons/152x152.png","settings":"unpackage/res/icons/29x29.png","proapp@2x":"unpackage/res/icons/167x167.png","spotlight":"unpackage/res/icons/40x40.png","settings@2x":"unpackage/res/icons/58x58.png","spotlight@2x":"unpackage/res/icons/80x80.png","notification":"unpackage/res/icons/20x20.png","notification@2x":"unpackage/res/icons/40x40.png"},"appstore":"unpackage/res/icons/1024x1024.png"},"android": {"mdpi": "unpackage/res/icons/48x48.png", /*普通屏程序圖標,分辨率:48x48*/"ldpi": "unpackage/res/icons/48x48.png", /*大屏程序圖標,分辨率:48x48*/"hdpi": "unpackage/res/icons/72x72.png", /*高分屏程序圖標,分辨率:72x72*/"xhdpi": "unpackage/res/icons/96x96.png",/*720P高分屏程序圖標,分辨率:96x96*/"xxhdpi": "unpackage/res/icons/144x144.png","xxxhdpi":"unpackage/res/icons/192x192.png"}},"splashscreen": {"ios": {"iphone": {"default": "", /*iPhone3啟動圖片選,分辨率:320x480*/"retina35": "C:/Users/Administrator/Desktop/image/2019-12-27_105028.png",/*3.5英寸設備(iPhone4)啟動圖片,分辨率:640x960*/"retina40": "C:/Users/Administrator/Desktop/image/2019-12-27_105028.png",/*4.0 英寸設備(iPhone5/iPhone5s)啟動圖片,分辨率:640x1136*/"retina47": "",/*4.7 英寸設備(iPhone6)啟動圖片,分辨率:750x1334*/"retina55": "",/*5.5 英寸設備(iPhone6 Plus)啟動圖片,分辨率:1242x2208*/"retina55l": ""},"ipad": {"portrait": "C:/Users/Administrator/Desktop/image/2019-12-27_105019.png", /*iPad豎屏啟動圖片,分辨率:768x1004*/"portrait-retina": "C:/Users/Administrator/Desktop/image/2019-12-27_105028.png",/*iPad高分屏豎屏圖片,分辨率:1536x2008*/"landscape": "C:/Users/Administrator/Desktop/image/2019-12-27_105028.png", /*iPad橫屏啟動圖片,分辨率:1024x748*/"landscape-retina": "C:/Users/Administrator/Desktop/image/2019-12-27_105028.png", /*iPad高分屏橫屏啟動圖片,分辨率:2048x1496*/"portrait7": "C:/Users/Administrator/Desktop/image/2019-12-27_105028.png", /*iPad iOS7豎屏啟動圖片,分辨率:768x1024*/"portrait-retina7": "C:/Users/Administrator/Desktop/image/2019-12-27_105028.png",/*iPad iOS7高分屏豎屏圖片,分辨率:1536x2048*/"landscape7": "C:/Users/Administrator/Desktop/image/2019-12-27_105028.png", /*iPad iOS7橫屏啟動圖片,分辨率:1024x768*/"landscape-retina7": "C:/Users/Administrator/Desktop/image/2019-12-27_105028.png"}},"android": {"mdpi": "", /*普通屏啟動圖片,分辨率:240x282*/"ldpi": "", /*大屏啟動圖片,分辨率:320x442*/"hdpi": "C:/Users/Administrator/Desktop/image/2019-12-27_105028.png", /*高分屏啟動圖片,分辨率:480x762*/"xhdpi": "C:/Users/Administrator/Desktop/image/2019-12-27_105028.png", /*720P高分屏啟動圖片,分辨率:720x1242*/"xxhdpi": "C:/Users/Administrator/Desktop/image/2019-12-27_105028.png"}}},"adid":"127239160201"}
}
以上配置 我打包后 雖然 pad 設置了 屏幕自動旋轉 但是 app 進去 后 仍然無效 查詢相關的一些帖子 然后在app.js 文件中 加了一些代碼
下面是app.js 的全部代碼 大部分代碼 都是 在 Hbuilder 創建項目的時候 自動生成的 主要還是 fullScreenOfAndroid ,fullScreenOfIos 這兩個 function
App({options: {debug: false},/*** 當wap2app初始化完成時,會觸發 onLaunch*/onLaunch: function() {console.log('launch');},/*** 當wap2app啟動,或從后臺進入前臺顯示,會觸發 onShow*/onShow: function() {console.log('show');},/*** 當wap2app從前臺進入后臺,會觸發 onHide*/onHide: function() {console.log('hide');};var fullScreenOfAndroid = function() {if(true) {var playym = plus.webview.currentWebview();playym.setStyle({videoFullscreen: 'landscape'})} else {document.addEventListener('webkitfullscreenchange', function() {var el = document.webkitFullscreenElement;if(el) {plus.screen.lockOrientation('landscape')} else {plus.screen.unlockOrientation()}})}};var fullScreenOfIos = function(videoElem) {videoElem.addEventListener('webkitbeginfullscreen', function() {plus.screen.lockOrientation('landscape')});videoElem.addEventListener('webkitendfullscreen', function() {plus.screen.unlockOrientation()})};});
Page('appid', { //首頁擴展配置onShow: function() {},onClose: function() {}
});
如果 你有自己的H5 也可以 自己去創建一個空殼 只需要 加上你 H5的請求地址 就可以了
下面是創建app 項目 wap站首頁地址 可以配置 你H5的登錄頁 也可以是 你的index 頁面 然后 會有一些 配置 你可以去百度 manifest.json 這個 配置文件 配置一下 就可以了 很方便 打包后直接 可以安裝 到手機上
當然 你的 H5前提是做了 自適應 不然 樣式會很丑的
總結
以上是生活随笔為你收集整理的解决 Hbuilder打包 Apk pad 无法横屏 以及 H5 直接打包 成Apk的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。