提交 5f20eac5 编写于 作者: Q qiang

Merge branch 'dev' into alpha

# Conflicts:
#	src/platforms/app-plus/service/api/device/system.js
#	src/platforms/h5/service/api/device/get-system-info.js
#	src/platforms/mp-weixin/helpers/enhance-system-info.js
......@@ -19,7 +19,7 @@ export function getDeviceInfo () {
weexGetSystemInfoSync()
const {
deviceBrand, deviceModel, osName,
osVersion
osVersion, deviceOrientation, deviceType
} = systemInfo
const brand = deviceBrand.toLowerCase()
......@@ -27,6 +27,10 @@ export function getDeviceInfo () {
return {
deviceBrand: brand,
deviceModel,
devicePixelRatio: plus.screen.scale,
deviceId: deviceId(),
deviceOrientation,
deviceType,
brand,
model: deviceModel,
system: `${osName === 'ios' ? 'iOS' : 'Android'} ${osVersion}`,
......@@ -37,7 +41,7 @@ export function getDeviceInfo () {
export function getAppBaseInfo () {
weexGetSystemInfoSync()
const {
hostPackageName, hostName, osLanguage,
hostPackageName, hostName,
hostVersion, hostLanguage, hostTheme,
appId, appName, appVersion, appVersionCode
} = systemInfo
......@@ -52,7 +56,7 @@ export function getAppBaseInfo () {
appVersionCode,
appLanguage: uni.getLocale(),
version: plus.runtime.innerVersion,
language: osLanguage,
language: hostLanguage,
theme: '',
hostPackageName,
hostName,
......@@ -71,11 +75,12 @@ export function getSystemInfo () {
_initSystemInfo = true
weexGetSystemInfoSync()
_initSystemInfo = false
const windowInfo = getWindowInfo()
const deviceInfo = getDeviceInfo()
const appBaseInfo = getAppBaseInfo()
_initSystemInfo = true
const { osName, osLanguage, osVersion, pixelRatio } = systemInfo
const { osName, osLanguage, osVersion } = systemInfo
const osLanguageSplit = osLanguage.split('-')
const osLanguageSplitLast = osLanguageSplit[osLanguageSplit.length - 1]
const _osLanguage = `${osLanguageSplit[0]}${osLanguageSplitLast ? '-' + osLanguageSplitLast : ''}`
......@@ -83,8 +88,6 @@ export function getSystemInfo () {
const extraData = {
errMsg: 'getSystemInfo:ok',
fontSizeSetting: appBaseInfo.hostFontSizeSetting,
devicePixelRatio: pixelRatio,
deviceId: deviceId(),
uniCompileVersion: __uniConfig.compilerVersion,
uniRuntimeVersion: __uniConfig.compilerVersion,
osLanguage: _osLanguage
......@@ -98,7 +101,7 @@ export function getSystemInfo () {
const _systemInfo = Object.assign(
{},
systemInfo,
getWindowInfo(),
windowInfo,
deviceInfo,
appBaseInfo,
extraData
......
......@@ -18,12 +18,18 @@ export function getDeviceInfo () {
brand,
model,
platform,
system
system,
deviceOrientation,
deviceType
} = browserInfo
return {
deviceBrand,
deviceModel,
devicePixelRatio: window.devicePixelRatio,
deviceId: deviceId(),
deviceOrientation,
deviceType,
brand,
model,
system,
......@@ -73,8 +79,7 @@ export function 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 = Object.assign(
{},
......@@ -83,12 +88,8 @@ export function getSystemInfoSync () {
appBaseInfo,
{
ua,
deviceType,
browserName,
browseVersion,
deviceId: deviceId(),
devicePixelRatio: pixelRatio,
deviceOrientation,
uniPlatform: 'web',
uniCompileVersion: __uniConfig.compilerVersion,
uniRuntimeVersion: __uniConfig.compilerVersion,
......
function getDeviceBrand (model) {
function _getDeviceBrand (model) {
if (/iphone/gi.test(model) || /ipad/gi.test(model) || /mac/gi.test(model)) { return 'apple' }
if (/windows/gi.test(model)) { return 'microsoft' }
return ''
}
const UUID_KEY = '__DC_STAT_UUID'
......@@ -31,8 +32,8 @@ export function addSafeAreaInsets (result) {
export function populateParameters (result) {
const {
brand, model, system,
language, theme, version,
brand = '', model = '', system = '',
language = '', theme, version,
hostName, platform, fontSizeSetting,
SDKVersion, pixelRatio, deviceOrientation,
environment
......@@ -59,38 +60,17 @@ export function populateParameters (result) {
}
// deviceType
let deviceType = result.deviceType || 'phone'
if (__PLATFORM__ !== 'mp-baidu') {
const deviceTypeMaps = {
ipad: 'pad',
windows: 'pc',
mac: 'pc'
}
const deviceTypeMapsKeys = Object.keys(deviceTypeMaps)
const _model = model.toLocaleLowerCase()
for (let index = 0; index < deviceTypeMapsKeys.length; index++) {
const _m = deviceTypeMapsKeys[index]
if (_model.indexOf(_m) !== -1) {
deviceType = deviceTypeMaps[_m]
break
}
}
}
const deviceType = getGetDeviceType(result, model)
// deviceModel
let deviceBrand = model.split(' ')[0].toLocaleLowerCase()
if (__PLATFORM__ === 'mp-toutiao' || __PLATFORM__ === 'mp-lark' || isQuickApp) {
deviceBrand = brand.toLocaleLowerCase()
} else {
deviceBrand = getDeviceBrand(deviceBrand)
}
const deviceBrand = getDeviceBrand(brand, model, isQuickApp)
// hostName
let _hostName = hostName || __PLATFORM__.split('-')[1] // mp-jd
if (__PLATFORM__ === 'mp-weixin') {
if (environment) {
_hostName = environment
} else if (result.host) {
} else if (result.host && result.host.env) {
_hostName = result.host.env
}
}
......@@ -130,7 +110,7 @@ export function populateParameters (result) {
osVersion,
hostTheme: theme,
hostVersion,
hostLanguage: language.split('_', '-'),
hostLanguage: language.replace('_', '-'),
hostName: _hostName,
hostSDKVersion: _SDKVersion,
hostFontSizeSetting: fontSizeSetting,
......@@ -147,3 +127,42 @@ export function populateParameters (result) {
Object.assign(result, parameters)
}
export function getGetDeviceType (result, model) {
let deviceType = result.deviceType || 'phone'
if (__PLATFORM__ !== 'mp-baidu') {
const deviceTypeMaps = {
ipad: 'pad',
windows: 'pc',
mac: 'pc'
}
const deviceTypeMapsKeys = Object.keys(deviceTypeMaps)
const _model = model.toLocaleLowerCase()
for (let index = 0; index < deviceTypeMapsKeys.length; index++) {
const _m = deviceTypeMapsKeys[index]
if (_model.indexOf(_m) !== -1) {
deviceType = deviceTypeMaps[_m]
break
}
}
}
return deviceType
}
export function getDeviceBrand (
brand,
model,
isQuickApp = false
) {
let deviceBrand = model.split(' ')[0].toLocaleLowerCase()
if (
__PLATFORM__ === 'mp-toutiao' ||
__PLATFORM__ === 'mp-lark' ||
isQuickApp
) {
deviceBrand = brand.toLocaleLowerCase()
} else {
deviceBrand = _getDeviceBrand(deviceBrand)
}
return deviceBrand
}
export default {
returnValue: function (result) {
const { version, language, SDKVersion, theme } = result
let _hostName = __PLATFORM__.split('-')[1] // mp-jd
if (__PLATFORM__ === 'mp-weixin') {
if (result.host && result.host.env) {
_hostName = result.host.env
}
}
Object.assign(result, {
hostVersion: version,
hostLanguage: language.replace('_', '-'),
hostName: _hostName,
hostSDKVersion: SDKVersion,
hostTheme: theme,
appId: process.env.UNI_APP_ID,
appName: process.env.UNI_APP_NAME,
appVersion: process.env.UNI_APP_VERSION_NAME,
appVersionCode: process.env.UNI_APP_VERSION_CODE
})
}
}
import { useDeviceId, getGetDeviceType, getDeviceBrand } from './enhance-system-info'
export default {
returnValue: function (result) {
const { brand, model } = result
const deviceType = getGetDeviceType(result, model)
const deviceBrand = getDeviceBrand(brand, model)
useDeviceId(result)
Object.assign(result, {
deviceType,
deviceBrand,
deviceModel: model
})
}
}
import { addSafeAreaInsets } from './enhance-system-info'
export default {
returnValue: function (result) {
addSafeAreaInsets(result)
Object.assign(result, {
windowTop: 0,
windowBottom: 0
})
}
}
......@@ -3,6 +3,9 @@ import redirectTo from '../../helpers/redirect-to'
import previewImage from '../../helpers/normalize-preview-image'
import getSystemInfo from '../../helpers/system-info'
import showActionSheet from '../../helpers/show-action-sheet'
import getAppBaseInfo from '../../helpers/get-app-base-info'
import getDeviceInfo from '../../helpers/get-device-info'
import getWindowInfo from '../../helpers/get-window-info'
export const protocols = {
redirectTo,
......@@ -10,7 +13,10 @@ export const protocols = {
previewImage,
getSystemInfo,
getSystemInfoSync: getSystemInfo,
showActionSheet
showActionSheet,
getAppBaseInfo,
getDeviceInfo,
getWindowInfo
}
export const todos = [
'vibrate',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册