Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ripplebb
uni-app
提交
a121dc67
U
uni-app
项目概览
ripplebb
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a121dc67
编写于
4月 28, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: getSystemInfo
上级
890829eb
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
240 addition
and
63 deletion
+240
-63
packages/vue-cli-plugin-uni/lib/chain-webpack.js
packages/vue-cli-plugin-uni/lib/chain-webpack.js
+4
-1
packages/vue-cli-plugin-uni/lib/env.js
packages/vue-cli-plugin-uni/lib/env.js
+8
-5
packages/webpack-uni-pages-loader/lib/platforms/h5.js
packages/webpack-uni-pages-loader/lib/platforms/h5.js
+5
-0
src/core/service/api/context/canvas.js
src/core/service/api/context/canvas.js
+1
-1
src/platforms/app-plus/service/api/device/system.js
src/platforms/app-plus/service/api/device/system.js
+17
-11
src/platforms/h5/service/api/device/get-system-info.js
src/platforms/h5/service/api/device/get-system-info.js
+52
-1
src/platforms/mp-alipay/helpers/system-info.js
src/platforms/mp-alipay/helpers/system-info.js
+2
-12
src/platforms/mp-jd/runtime/api/protocols.js
src/platforms/mp-jd/runtime/api/protocols.js
+3
-3
src/platforms/mp-weixin/helpers/enhance-system-info.js
src/platforms/mp-weixin/helpers/enhance-system-info.js
+114
-0
src/platforms/mp-weixin/helpers/system-info.js
src/platforms/mp-weixin/helpers/system-info.js
+3
-26
src/platforms/mp-xhs/runtime/api/protocols.js
src/platforms/mp-xhs/runtime/api/protocols.js
+3
-3
src/shared/util.js
src/shared/util.js
+28
-0
未找到文件。
packages/vue-cli-plugin-uni/lib/chain-webpack.js
浏览文件 @
a121dc67
...
...
@@ -104,7 +104,10 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
'
process.env.RUN_BY_HBUILDERX
'
:
process
.
env
.
RUN_BY_HBUILDERX
,
'
process.env.UNI_AUTOMATOR_WS_ENDPOINT
'
:
JSON
.
stringify
(
process
.
env
.
UNI_AUTOMATOR_WS_ENDPOINT
),
'
process.env.UNI_STAT_UNI_CLOUD
'
:
process
.
env
.
UNI_STAT_UNI_CLOUD
||
''
,
'
process.env.UNI_STAT_DEBUG
'
:
process
.
env
.
UNI_STAT_DEBUG
||
''
'
process.env.UNI_STAT_DEBUG
'
:
process
.
env
.
UNI_STAT_DEBUG
||
''
,
'
process.env.UNI_COMPILER_VERSION
'
:
JSON
.
stringify
(
process
.
env
.
UNI_COMPILER_VERSION
),
'
process.env.UNI_APP_VERSION_NAME
'
:
JSON
.
stringify
(
process
.
env
.
UNI_APP_VERSION_NAME
),
'
process.env.UNI_APP_VERSION_CODE
'
:
JSON
.
stringify
(
process
.
env
.
UNI_APP_VERSION_CODE
)
}
if
(
process
.
env
.
UNI_USING_VUE3
)
{
Object
.
assign
(
defines
,
{
...
...
packages/vue-cli-plugin-uni/lib/env.js
浏览文件 @
a121dc67
...
...
@@ -31,6 +31,8 @@ const manifestJsonObj = getManifestJson()
process
.
env
.
UNI_APP_ID
=
manifestJsonObj
.
appid
||
''
process
.
env
.
UNI_APP_NAME
=
manifestJsonObj
.
name
||
''
process
.
env
.
UNI_PLATFORM
=
process
.
env
.
UNI_PLATFORM
||
'
h5
'
process
.
env
.
UNI_APP_VERSION_NAME
=
manifestJsonObj
.
versionName
process
.
env
.
UNI_APP_VERSION_CODE
=
manifestJsonObj
.
versionCode
// 小程序 vue3 标记
if
(
process
.
env
.
UNI_PLATFORM
.
indexOf
(
'
mp-
'
)
===
0
)
{
...
...
@@ -388,6 +390,11 @@ const warningMsg =
const
needWarning
=
!
platformOptions
.
usingComponents
||
usingComponentsAbsent
let
hasNVue
=
false
// 输出编译器版本等信息
const
pagesPkg
=
require
(
'
@dcloudio/webpack-uni-pages-loader/package.json
'
)
process
.
env
.
UNI_COMPILER_VERSION
=
''
if
(
pagesPkg
)
{
process
.
env
.
UNI_COMPILER_VERSION
=
pagesPkg
[
'
uni-app
'
].
compilerVersion
}
const
compileModeUrl
=
'
https://ask.dcloud.net.cn/article/36074
'
if
(
process
.
env
.
UNI_USING_NATIVE
||
process
.
env
.
UNI_USING_V3_NATIVE
)
{
const
compileMode
=
(
process
.
env
.
UNI_USING_V3_NATIVE
?
'
(v3)
'
:
''
)
+
'
:
'
+
(
isNVueCompiler
?
'
uni-app
'
:
'
weex
'
)
...
...
@@ -397,12 +404,8 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
}))
}
else
if
(
process
.
env
.
UNI_PLATFORM
!==
'
h5
'
&&
process
.
env
.
UNI_PLATFORM
!==
'
quickapp-native
'
)
{
try
{
let
info
=
''
let
info
=
process
.
env
.
UNI_COMPILER_VERSION
if
(
process
.
env
.
UNI_PLATFORM
===
'
app-plus
'
)
{
const
pagesPkg
=
require
(
'
@dcloudio/webpack-uni-pages-loader/package.json
'
)
if
(
pagesPkg
)
{
info
=
uniI18n
.
__
(
'
compilerVersion
'
)
+
'
:
'
+
pagesPkg
[
'
uni-app
'
].
compilerVersion
}
if
(
process
.
env
.
UNI_USING_V3
)
{
console
.
log
(
info
)
}
else
{
...
...
packages/webpack-uni-pages-loader/lib/platforms/h5.js
浏览文件 @
a121dc67
...
...
@@ -443,6 +443,11 @@ global['____${h5.appid}____'] = true;
delete global['____
${
h5
.
appid
}
____'];
global.__uniConfig =
${
JSON
.
stringify
(
pagesJson
)}
;
global.__uniConfig.compilerVersion = '
${
compilerVersion
}
';
global.__uniConfig.uniPlatform = '
${
process
.
env
.
UNI_PLATFORM
}
';
global.__uniConfig.appId = '
${
process
.
env
.
UNI_APP_ID
}
';
global.__uniConfig.appName = '
${
process
.
env
.
UNI_APP_NAME
}
';
global.__uniConfig.appVersion = '
${
process
.
env
.
UNI_APP_VERSION_NAME
}
';
global.__uniConfig.appVersionCode = '
${
process
.
env
.
UNI_APP_VERSION_CODE
}
';
global.__uniConfig.router =
${
JSON
.
stringify
(
h5
.
router
)}
;
global.__uniConfig.publicPath =
${
JSON
.
stringify
(
h5
.
publicPath
)}
;
global.__uniConfig['async'] =
${
JSON
.
stringify
(
h5
.
async
)}
;
...
...
src/core/service/api/context/canvas.js
浏览文件 @
a121dc67
...
...
@@ -372,7 +372,7 @@ export class CanvasContext {
this
.
path
=
[]
this
.
subpath
=
[]
this
.
path
.
push
({
method
:
"
beginPath
"
,
method
:
'
beginPath
'
,
data
:
[]
})
}
...
...
src/platforms/app-plus/service/api/device/system.js
浏览文件 @
a121dc67
...
...
@@ -18,9 +18,12 @@ export function getSystemInfoSync () {
}
export
function
getSystemInfo
()
{
const
platform
=
plus
.
os
.
name
.
toLowerCase
()
const
ios
=
platform
===
'
ios
'
const
isAndroid
=
platform
===
'
android
'
const
{
getSystemInfoSync
}
=
weex
.
requireModule
(
'
plus
'
)
const
info
=
getSystemInfoSync
()
const
{
deviceBrand
,
deviceModel
,
osName
,
osVersion
,
osLanguage
}
=
info
const
brand
=
deviceBrand
.
toLowerCase
()
const
_osName
=
osName
.
toLowerCase
()
const
ios
=
_osName
===
'
ios
'
const
{
screenWidth
,
screenHeight
...
...
@@ -76,21 +79,21 @@ export function getSystemInfo () {
height
:
windowHeightReal
-
safeAreaInsets
.
top
-
safeAreaInsets
.
bottom
}
return
{
return
Object
.
assign
(
{
errMsg
:
'
getSystemInfo:ok
'
,
brand
:
plus
.
device
.
vendor
,
model
:
plus
.
device
.
m
odel
,
brand
:
brand
,
model
:
deviceM
odel
,
pixelRatio
:
plus
.
screen
.
scale
,
screenWidth
,
screenHeight
,
windowWidth
,
windowHeight
,
statusBarHeight
,
language
:
plus
.
os
.
l
anguage
,
system
:
`
${
ios
?
'
iOS
'
:
isAndroid
?
'
Android
'
:
''
}
${
plus
.
os
.
v
ersion
}
`
,
language
:
osL
anguage
,
system
:
`
${
osName
}
${
osV
ersion
}
`
,
version
:
plus
.
runtime
.
innerVersion
,
fontSizeSetting
:
''
,
platform
,
platform
:
_osName
,
SDKVersion
:
''
,
windowTop
,
windowBottom
,
...
...
@@ -102,5 +105,8 @@ export function getSystemInfo () {
left
:
safeAreaInsets
.
left
},
deviceId
:
deviceId
()
}
}
},
info
,
{
deviceBrand
:
brand
,
osName
:
_osName
})
}
src/platforms/h5/service/api/device/get-system-info.js
浏览文件 @
a121dc67
import
getWindowOffset
from
'
uni-platform/helpers/get-window-offset
'
import
deviceId
from
'
uni-platform/helpers/uuid
'
import
safeAreaInsets
from
'
safe-area-insets
'
import
{
IEVersion
,
getDeviceBrand
}
from
'
uni-shared
'
const
ua
=
navigator
.
userAgent
/**
...
...
@@ -45,6 +46,7 @@ export function getSystemInfoSync () {
var
osname
var
osversion
var
model
let
deviceType
=
'
phone
'
if
(
isIOS
)
{
osname
=
'
iOS
'
...
...
@@ -89,8 +91,11 @@ export function getSystemInfoSync () {
model
=
'
iPad
'
osname
=
'
iOS
'
osversion
=
typeof
window
.
BigInt
===
'
function
'
?
'
14.0
'
:
'
13.0
'
deviceType
=
'
pad
'
}
else
if
(
isWindows
||
isMac
||
isLinux
)
{
model
=
'
PC
'
osname
=
'
PC
'
deviceType
=
'
pc
'
const
osversionFind
=
ua
.
match
(
/
\((
.+
?)\)
/
)[
1
]
if
(
isWindows
)
{
...
...
@@ -147,6 +152,7 @@ export function getSystemInfoSync () {
}
else
{
osname
=
'
Other
'
osversion
=
'
0
'
deviceType
=
'
other
'
}
var
system
=
`
${
osname
}
${
osversion
}
`
...
...
@@ -168,6 +174,30 @@ export function getSystemInfoSync () {
windowHeight
-=
windowTop
windowHeight
-=
windowBottom
let
browserName
let
browseVersion
=
String
(
IEVersion
())
if
(
browseVersion
!==
'
-1
'
)
{
browserName
=
'
IE
'
}
else
{
const
browseVendors
=
[
'
Version
'
,
'
Firefox
'
,
'
Chrome
'
,
'
Edge{0,1}
'
]
const
vendors
=
[
'
Safari
'
,
'
Firefox
'
,
'
Chrome
'
,
'
Edge
'
]
for
(
let
index
=
0
;
index
<
browseVendors
.
length
;
index
++
)
{
const
vendor
=
browseVendors
[
index
]
const
reg
=
new
RegExp
(
`(
${
vendor
}
)/(\\S*)\\b`
)
if
(
reg
.
test
(
ua
))
{
browserName
=
vendors
[
index
]
browseVersion
=
ua
.
match
(
reg
)[
2
]
}
}
}
// deviceBrand
let
deviceBrand
=
''
if
(
model
)
{
const
_model
=
model
.
toLocaleLowerCase
()
deviceBrand
=
getDeviceBrand
(
_model
)
||
getDeviceBrand
(
osname
.
toLocaleLowerCase
())
||
_model
.
split
(
'
'
)[
0
]
}
return
{
windowTop
,
windowBottom
,
...
...
@@ -180,7 +210,10 @@ export function getSystemInfoSync () {
statusBarHeight
,
system
,
platform
,
deviceBrand
,
deviceType
,
model
,
deviceModel
:
model
,
safeArea
,
safeAreaInsets
:
{
top
:
safeAreaInsets
.
top
,
...
...
@@ -188,7 +221,25 @@ export function getSystemInfoSync () {
bottom
:
safeAreaInsets
.
bottom
,
left
:
safeAreaInsets
.
left
},
deviceId
:
deviceId
()
deviceId
:
deviceId
(),
SDKVersion
:
''
,
ua
,
uniPlatform
:
'
web
'
,
browserName
,
browseVersion
,
osLanguage
:
language
,
osName
:
osname
,
osVersion
:
osversion
,
hostLanguage
:
language
,
version
:
__uniConfig
.
appVersion
,
uniCompileVersion
:
__uniConfig
.
compilerVersion
,
uniRuntimeVersion
:
__uniConfig
.
compilerVersion
,
appId
:
__uniConfig
.
appId
,
appName
:
__uniConfig
.
appName
,
appVersion
:
__uniConfig
.
appVersion
,
appVersionCode
:
__uniConfig
.
appVersionCode
,
osTheme
:
''
,
hostTheme
:
''
}
}
/**
...
...
src/platforms/mp-alipay/helpers/system-info.js
浏览文件 @
a121dc67
import
{
getStorageSync
}
from
'
./storage
'
import
{
addSafeAreaInsets
,
populateParameters
}
from
'
../../mp-weixin/helpers/enhance-system-info
'
const
UUID_KEY
=
'
__DC_STAT_UUID
'
let
deviceId
...
...
@@ -14,18 +15,6 @@ function addUuid (result) {
result
.
deviceId
=
deviceId
}
function
addSafeAreaInsets
(
result
)
{
if
(
result
.
safeArea
)
{
const
safeArea
=
result
.
safeArea
result
.
safeAreaInsets
=
{
top
:
safeArea
.
top
,
left
:
safeArea
.
left
,
right
:
result
.
windowWidth
-
safeArea
.
right
,
bottom
:
result
.
windowHeight
-
safeArea
.
bottom
}
}
}
function
normalizePlatform
(
result
)
{
let
platform
=
result
.
platform
?
result
.
platform
.
toLowerCase
()
:
'
devtools
'
if
(
!~
[
'
android
'
,
'
ios
'
].
indexOf
(
platform
))
{
...
...
@@ -39,5 +28,6 @@ export default {
addUuid
(
result
)
addSafeAreaInsets
(
result
)
normalizePlatform
(
result
)
populateParameters
(
result
)
}
}
src/platforms/mp-jd/runtime/api/protocols.js
浏览文件 @
a121dc67
// import navigateTo from 'uni-helpers/navigate-to'
// import redirectTo from '../../../mp-weixin/helpers/redirect-to'
// import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
//
import getSystemInfo from '../../../mp-weixin/helpers/system-info'
import
getSystemInfo
from
'
../../../mp-weixin/helpers/system-info
'
// import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
// 需要做转换的 API 列表
...
...
@@ -9,8 +9,8 @@ export const protocols = {
// navigateTo,
// redirectTo,
// previewImage,
//
getSystemInfo,
// getSystemInfoSync: getSystemInfo,
getSystemInfo
,
getSystemInfoSync
:
getSystemInfo
// getUserProfile
}
...
...
src/platforms/mp-weixin/helpers/enhance-system-info.js
0 → 100644
浏览文件 @
a121dc67
import
{
getDeviceBrand
}
from
'
uni-shared
'
const
UUID_KEY
=
'
__DC_STAT_UUID
'
let
deviceId
export
function
useDeviceId
(
result
)
{
deviceId
=
deviceId
||
__GLOBAL__
.
getStorageSync
(
UUID_KEY
)
if
(
!
deviceId
)
{
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
)
__GLOBAL__
.
setStorage
({
key
:
UUID_KEY
,
data
:
deviceId
})
}
result
.
deviceId
=
deviceId
}
export
function
addSafeAreaInsets
(
result
)
{
if
(
result
.
safeArea
)
{
const
safeArea
=
result
.
safeArea
result
.
safeAreaInsets
=
{
top
:
safeArea
.
top
,
left
:
safeArea
.
left
,
right
:
result
.
windowWidth
-
safeArea
.
right
,
bottom
:
result
.
screenHeight
-
safeArea
.
bottom
}
}
}
export
function
populateParameters
(
result
)
{
const
{
brand
,
model
,
system
,
language
,
theme
,
version
,
hostName
,
platform
}
=
result
// osName osVersion
let
osName
=
''
let
osVersion
=
''
if
(
__PLATFORM__
===
'
mp-alipay
'
)
{
osName
=
platform
.
toLocaleLowerCase
()
osVersion
=
system
}
else
{
osName
=
system
.
split
(
'
'
)[
0
]
||
''
osVersion
=
system
.
split
(
'
'
)[
1
]
||
''
}
let
hostVersion
=
version
// host 枚举值 https://smartprogram.baidu.com/docs/develop/api/device_sys/hostlist/
if
(
__PLATFORM__
===
'
mp-baidu
'
)
{
hostVersion
=
result
.
swanNativeVersion
||
version
}
// 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
}
}
}
// deviceModel
let
deviceBrand
=
model
.
split
(
'
'
)[
0
].
toLocaleLowerCase
()
if
(
__PLATFORM__
===
'
mp-toutiao
'
||
__PLATFORM__
===
'
mp-lark
'
)
{
deviceBrand
=
brand
.
toLocaleLowerCase
()
}
else
{
deviceBrand
=
getDeviceBrand
(
deviceBrand
)
}
// hostName
let
_hostName
=
hostName
// mp-jd
if
(
__PLATFORM__
===
'
mp-weixin
'
)
_hostName
=
(
result
.
host
||
{}).
env
if
(
__PLATFORM__
===
'
mp-baidu
'
||
__PLATFORM__
===
'
mp-kuaishou
'
)
_hostName
=
result
.
host
if
(
__PLATFORM__
===
'
mp-qq
'
)
_hostName
=
result
.
AppPlatform
if
(
__PLATFORM__
===
'
mp-toutiao
'
||
__PLATFORM__
===
'
mp-lark
'
)
_hostName
=
result
.
appName
if
(
__PLATFORM__
===
'
mp-alipay
'
)
_hostName
=
result
.
app
// wx.getAccountInfoSync
const
parameters
=
{
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
,
uniCompileVersion
:
process
.
env
.
UNI_COMPILER_VERSION
,
uniRuntimeVersion
:
process
.
env
.
UNI_COMPILER_VERSION
,
uniPlatform
:
process
.
env
.
UNI_PLATFORM
,
deviceBrand
,
deviceModel
:
model
,
deviceType
,
osName
,
osVersion
,
osLanguage
:
language
,
osTheme
:
theme
,
hostVersion
,
hostLanguage
:
language
,
hostName
:
_hostName
,
// TODO
ua
:
''
,
hostTheme
:
''
,
hostPackageName
:
''
,
browserName
:
''
,
browseVersion
:
''
}
Object
.
assign
(
result
,
parameters
)
}
\ No newline at end of file
src/platforms/mp-weixin/helpers/system-info.js
浏览文件 @
a121dc67
const
UUID_KEY
=
'
__DC_STAT_UUID
'
let
deviceId
function
addUuid
(
result
)
{
deviceId
=
deviceId
||
__GLOBAL__
.
getStorageSync
(
UUID_KEY
)
if
(
!
deviceId
)
{
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
)
__GLOBAL__
.
setStorage
({
key
:
UUID_KEY
,
data
:
deviceId
})
}
result
.
deviceId
=
deviceId
}
function
addSafeAreaInsets
(
result
)
{
if
(
result
.
safeArea
)
{
const
safeArea
=
result
.
safeArea
result
.
safeAreaInsets
=
{
top
:
safeArea
.
top
,
left
:
safeArea
.
left
,
right
:
result
.
windowWidth
-
safeArea
.
right
,
bottom
:
Math
.
abs
(
result
.
screenHeight
-
safeArea
.
bottom
)
}
}
}
import
{
useDeviceId
,
addSafeAreaInsets
,
populateParameters
}
from
'
./enhance-system-info
'
export
default
{
returnValue
:
function
(
result
)
{
addUui
d
(
result
)
useDeviceI
d
(
result
)
addSafeAreaInsets
(
result
)
populateParameters
(
result
)
}
}
src/platforms/mp-xhs/runtime/api/protocols.js
浏览文件 @
a121dc67
// import navigateTo from 'uni-helpers/navigate-to'
// import redirectTo from '../../../mp-weixin/helpers/redirect-to'
// import previewImage from '../../../mp-weixin/helpers/normalize-preview-image'
//
import getSystemInfo from '../../../mp-weixin/helpers/system-info'
import
getSystemInfo
from
'
../../../mp-weixin/helpers/system-info
'
// import getUserProfile from '../../../mp-weixin/helpers/get-user-profile'
// 需要做转换的 API 列表
...
...
@@ -9,8 +9,8 @@ export const protocols = {
// navigateTo,
// redirectTo,
// previewImage,
//
getSystemInfo,
// getSystemInfoSync: getSystemInfo,
getSystemInfo
,
getSystemInfoSync
:
getSystemInfo
// getUserProfile
}
...
...
src/shared/util.js
浏览文件 @
a121dc67
...
...
@@ -195,3 +195,31 @@ export function deepClone (vnodes, createElement) {
}
export
*
from
'
./uni-id-mixin
'
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
)
{
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录