uniapp获取设备信息:uni.getSystemInfo或uni.getSystemInfoSync,可用于设置顶部安全区
let sysInfo = uni.getSystemInfoSync(); console.log(sysInfo); //{SDKVersion: "2.33.0"
appId: "__UNI__EEB4CD4"
appLanguage: "zh-Hans"
appName: "sc-vue3"
appVersion: "0.0.1"
appVersionCode: 1
batteryLevel: 100
benchmarkLevel: 1
bluetoothEnabled: true
brand: "devtools"
browserName: undefined
browserVersion: undefined
cameraAuthorized: true
deviceBrand: "devtools"
deviceId: "16897597042117133529"
deviceModel: "iPhone XR"
deviceOrientation: "portrait"
devicePixelRatio: 2
deviceType: "phone"
enableDebug: false
fontSizeSetting: 16
hostFontSizeSetting: 16
hostLanguage: "zh-CN"
hostName: "WeChat"
hostPackageName: undefined
hostSDKVersion: "2.33.0"
hostTheme: undefined
hostVersion: "8.0.5"
language: "zh_CN"
locationAuthorized: true
locationEnabled: true
microphoneAuthorized: true
mode: "default"
model: "iPhone XR"
notificationAuthorized: true
osLanguage: undefined
osName: "ios"
osTheme: undefined
osVersion: "10.0.1"
pixelRatio: 2
platform: "devtools"
safeArea: {top: 44, left: 0, right: 414, bottom: 862, width: 414, …}//安全区信息
safeAreaInsets: {top: 44, left: 0, right: 0, bottom: 34}//安全区信息
screenHeight: 896
screenWidth: 414
statusBarHeight: 44 //顶部安全区高度,单位是px需要自行转换 44px = 44/(windowWidth/750)rpx
system: "iOS 10.0.1"
ua: undefined
uniCompileVersion: "3.8.4"
uniPlatform: "mp-weixin"
uniRuntimeVersion: "3.8.4"
version: "8.0.5"
wifiEnabled: true
windowBottom: 0
windowHeight: 896//屏幕高度
windowTop: 0
windowWidth: 414//屏幕宽度