diff --git a/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts b/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts index b3f0c3248513a867d9a645ca423161fabaeabef6..b3d9e0348eec41955e6f860d6ef47413f1327597 100644 --- a/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts +++ b/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts @@ -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' + } +} + /** * 获取系统信息-同步 */ diff --git a/packages/uni-mp-core/src/api/protocols/enhanceSystemInfo.ts b/packages/uni-mp-core/src/api/protocols/enhanceSystemInfo.ts index 9c31da7f974a7974f172735ddc8dbc2fe31a0a35..2d3dc8015f027c0b8f3c6dbc4cc4210736ec2f0e 100644 --- a/packages/uni-mp-core/src/api/protocols/enhanceSystemInfo.ts +++ b/packages/uni-mp-core/src/api/protocols/enhanceSystemInfo.ts @@ -1,5 +1,13 @@ 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 diff --git a/packages/uni-shared/src/utils.ts b/packages/uni-shared/src/utils.ts index d57a8f98189d593779ee9a73b43a61a0089861a7..e0b3b4a556e68e6242df463795ba36fa40ddf5f1 100644 --- a/packages/uni-shared/src/utils.ts +++ b/packages/uni-shared/src/utils.ts @@ -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' - } -}