提交 f52b7959 编写于 作者: D DCloud_LXH

chore: 完善 getDeviceInfo

上级 614504ec
......@@ -16,13 +16,24 @@ export const getDeviceInfo = defineSyncApi<typeof uni.getDeviceInfo>(
'getDeviceInfo',
() => {
weexGetSystemInfoSync()
const { deviceBrand, deviceModel, osName, osVersion } = systemInfo
const {
deviceBrand,
deviceModel,
osName,
osVersion,
deviceOrientation,
deviceType,
} = systemInfo
const brand = deviceBrand.toLowerCase()
return {
deviceBrand: brand,
deviceModel,
devicePixelRatio: plus.screen.scale!,
deviceId: deviceId(),
deviceOrientation,
deviceType,
brand,
model: deviceModel,
system: `${osName === 'ios' ? 'iOS' : 'Android'} ${osVersion}`,
......@@ -82,7 +93,6 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
_initSystemInfo = true
const { osName, osLanguage, osVersion } = systemInfo
const { pixelRatio } = windowInfo
const osLanguageSplit = osLanguage.split('-')
const osLanguageSplitLast = osLanguageSplit[osLanguageSplit.length - 1]
let _osLanguage = `${osLanguageSplit[0]}${
......@@ -92,8 +102,6 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
let extraData = {
errMsg: 'getSystemInfo:ok',
fontSizeSetting: appBaseInfo.hostFontSizeSetting,
devicePixelRatio: pixelRatio,
deviceId: deviceId(),
uniCompileVersion: __uniConfig.compilerVersion,
uniRuntimeVersion: __uniConfig.compilerVersion,
osLanguage: _osLanguage,
......@@ -105,8 +113,8 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
}
const _systemInfo: UniApp.GetSystemInfoResult = extend(
windowInfo,
systemInfo,
windowInfo,
deviceInfo,
appBaseInfo,
extraData
......
......@@ -140,7 +140,7 @@ export function getBrowserInfo() {
osversion += ` x${framework[1]}`
}
} else if (isMac) {
osname = 'Mac'
osname = 'macOS'
const _osversion =
(osversionFind && osversionFind.match(/Mac OS X (.+)/)) || ''
......
......@@ -21,12 +21,24 @@ export const getDeviceInfo = defineSyncApi<typeof uni.getDeviceInfo>(
'getDeviceInfo',
() => {
initBrowserInfo()
const { deviceBrand, deviceModel, brand, model, platform, system } =
browserInfo
const {
deviceBrand,
deviceModel,
brand,
model,
platform,
system,
deviceOrientation,
deviceType,
} = browserInfo
return {
deviceBrand,
deviceModel,
devicePixelRatio: window.devicePixelRatio,
deviceId: deviceId(),
deviceOrientation,
deviceType,
brand,
model,
system,
......@@ -84,16 +96,7 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
const appBaseInfo = getAppBaseInfo()
_initBrowserInfo = true
const {
ua,
deviceType,
browserName,
browseVersion,
osname,
osversion,
deviceOrientation,
} = browserInfo
const { pixelRatio } = windowInfo
const { ua, browserName, browseVersion, osname, osversion } = browserInfo
const systemInfo: UniApp.GetSystemInfoResult = extend(
windowInfo,
......@@ -101,12 +104,8 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
appBaseInfo,
{
ua,
deviceType,
browserName,
browseVersion,
deviceId: deviceId(),
devicePixelRatio: pixelRatio,
deviceOrientation,
uniPlatform: 'web',
uniCompileVersion: __uniConfig.compilerVersion,
uniRuntimeVersion: __uniConfig.compilerVersion,
......
......@@ -172,7 +172,7 @@ export function populateParameters(
osVersion,
hostTheme: theme,
hostVersion,
hostLanguage: language.split('_', '-'),
hostLanguage: language.replace('_', '-'),
hostName: _hostName,
hostSDKVersion: _SDKVersion,
hostFontSizeSetting: fontSizeSetting,
......
......@@ -6,7 +6,7 @@ importers:
specifiers:
'@babel/core': ^7.17.10
'@babel/preset-env': ^7.16.11
'@dcloudio/types': ^2.6.9
'@dcloudio/types': ^2.6.10
'@dcloudio/uni-api': 3.0.0-alpha-3041020220516004
'@dcloudio/uni-app': 3.0.0-alpha-3041020220516004
'@jest/types': ^27.0.2
......@@ -57,7 +57,7 @@ importers:
devDependencies:
'@babel/core': 7.17.10
'@babel/preset-env': 7.17.10_@babel+core@7.17.10
'@dcloudio/types': 2.6.9
'@dcloudio/types': 2.6.10
'@dcloudio/uni-api': link:packages/uni-api
'@dcloudio/uni-app': link:packages/uni-app
'@jest/types': 27.5.1
......@@ -2105,12 +2105,12 @@ packages:
- supports-color
dev: true
/@dcloudio/types/2.6.6:
resolution: {integrity: sha512-ChLbkLuXfWxaj6VcsCcspIyC9+xIYKAJX++f50oCzUWbApslGwRpJ12wqS9k5Eg5euaHSzmyE0JfpZlNFpBk6w==}
/@dcloudio/types/2.6.10:
resolution: {integrity: sha512-KBMMb+vDw7XeobwKsBh9RY+yLuL9ZKaWWgRFctd62b1zMrsWhweIyyvigvqutgaE3wCwj7T71HoA7SHxC+SYnw==}
dev: true
/@dcloudio/types/2.6.9:
resolution: {integrity: sha512-fCOrtCpuVX5v3mceoNkOnBwGnrUyQo9oOqF/4d78RKRxpcPSdky65vfCi/WBq6L6uPyeyQEgFeOR9InINViMow==}
/@dcloudio/types/2.6.6:
resolution: {integrity: sha512-ChLbkLuXfWxaj6VcsCcspIyC9+xIYKAJX++f50oCzUWbApslGwRpJ12wqS9k5Eg5euaHSzmyE0JfpZlNFpBk6w==}
dev: true
/@dcloudio/uni-cli-i18n/2.0.0-alpha-33020211130001:
......@@ -8227,6 +8227,7 @@ packages:
rollup: 2.72.0
optionalDependencies:
fsevents: 2.3.2
dev: true
/vlq/0.2.3:
resolution: {integrity: sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册