提交 13c8eddb 编写于 作者: D DCloud_LXH

chore: uni-shared IEVersion、getDeviceBrand

上级 6a12080e
......@@ -3,7 +3,6 @@ import safeAreaInsets from 'safe-area-insets'
import { defineSyncApi } from '@dcloudio/uni-api'
import { getWindowOffset } from '@dcloudio/uni-core'
import { IEVersion, getDeviceBrand } from '@dcloudio/uni-shared'
import {
ua,
......@@ -22,6 +21,40 @@ import {
import deviceId from '../../../helpers/uuid'
function IEVersion() {
const userAgent = navigator.userAgent
const isIE =
userAgent.indexOf('compatible') > -1 && userAgent.indexOf('MSIE') > -1
const isEdge = userAgent.indexOf('Edge') > -1 && !isIE
const isIE11 =
userAgent.indexOf('Trident') > -1 && userAgent.indexOf('rv:11.0') > -1
if (isIE) {
const reIE = new RegExp('MSIE (\\d+\\.\\d+);')
reIE.test(userAgent)
const fIEVersion = parseFloat(RegExp.$1)
if (fIEVersion > 6) {
return fIEVersion
} else {
return 6
}
} else if (isEdge) {
return -1
} else if (isIE11) {
return 11
} else {
return -1
}
}
function getDeviceBrand(model: string) {
if (/iphone/gi.test(model) || /ipad/gi.test(model) || /mac/gi.test(model)) {
return 'apple'
}
if (/windows/gi.test(model)) {
return 'microsoft'
}
}
/**
* 获取系统信息-同步
*/
......
import { extend } from '@vue/shared'
import { getDeviceBrand } from '@dcloudio/uni-shared'
function getDeviceBrand(model: string) {
if (/iphone/gi.test(model) || /ipad/gi.test(model) || /mac/gi.test(model)) {
return 'apple'
}
if (/windows/gi.test(model)) {
return 'microsoft'
}
}
const UUID_KEY = '__DC_STAT_UUID'
let deviceId: string
......
......@@ -129,37 +129,3 @@ export function getValueByDataPath(obj: any, path: string): unknown {
}
return getValueByDataPath(obj[key], parts.slice(1).join('.'))
}
export function IEVersion() {
const userAgent = navigator.userAgent
const isIE =
userAgent.indexOf('compatible') > -1 && userAgent.indexOf('MSIE') > -1
const isEdge = userAgent.indexOf('Edge') > -1 && !isIE
const isIE11 =
userAgent.indexOf('Trident') > -1 && userAgent.indexOf('rv:11.0') > -1
if (isIE) {
const reIE = new RegExp('MSIE (\\d+\\.\\d+);')
reIE.test(userAgent)
const fIEVersion = parseFloat(RegExp.$1)
if (fIEVersion > 6) {
return fIEVersion
} else {
return 6
}
} else if (isEdge) {
return -1
} else if (isIE11) {
return 11
} else {
return -1
}
}
export function getDeviceBrand(model: string) {
if (/iphone/gi.test(model) || /ipad/gi.test(model) || /mac/gi.test(model)) {
return 'apple'
}
if (/windows/gi.test(model)) {
return 'microsoft'
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册