Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
0c59f2a4
U
uni-app
项目概览
DCloud
/
uni-app
5 天 前同步成功
通知
815
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
0c59f2a4
编写于
4月 28, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: getSystemInfo
上级
d4b24efc
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
303 addition
and
67 deletion
+303
-67
packages/shims-uni-app.d.ts
packages/shims-uni-app.d.ts
+5
-0
packages/uni-app-plus/src/service/api/device/systemInfo.ts
packages/uni-app-plus/src/service/api/device/systemInfo.ts
+39
-27
packages/uni-cli-shared/src/env/define.ts
packages/uni-cli-shared/src/env/define.ts
+6
-0
packages/uni-h5-vite/src/plugins/pagesJson.ts
packages/uni-h5-vite/src/plugins/pagesJson.ts
+10
-1
packages/uni-h5/src/service/api/device/getSystemInfoSync.ts
packages/uni-h5/src/service/api/device/getSystemInfoSync.ts
+49
-1
packages/uni-mp-alipay/src/api/protocols.ts
packages/uni-mp-alipay/src/api/protocols.ts
+6
-1
packages/uni-mp-core/src/api/protocols/addSafeAreaInsets.ts
packages/uni-mp-core/src/api/protocols/addSafeAreaInsets.ts
+0
-14
packages/uni-mp-core/src/api/protocols/enhanceSystemInfo.ts
packages/uni-mp-core/src/api/protocols/enhanceSystemInfo.ts
+128
-0
packages/uni-mp-core/src/api/protocols/getSystemInfo.ts
packages/uni-mp-core/src/api/protocols/getSystemInfo.ts
+6
-2
packages/uni-mp-core/src/api/protocols/index.ts
packages/uni-mp-core/src/api/protocols/index.ts
+5
-2
packages/uni-mp-core/src/api/protocols/useDeviceId.ts
packages/uni-mp-core/src/api/protocols/useDeviceId.ts
+0
-18
packages/uni-mp-core/src/index.ts
packages/uni-mp-core/src/index.ts
+1
-0
packages/uni-mp-toutiao/src/api/protocols.ts
packages/uni-mp-toutiao/src/api/protocols.ts
+7
-1
packages/uni-shared/src/utils.ts
packages/uni-shared/src/utils.ts
+34
-0
packages/vite-plugin-uni/src/index.ts
packages/vite-plugin-uni/src/index.ts
+7
-0
未找到文件。
packages/shims-uni-app.d.ts
浏览文件 @
0c59f2a4
...
...
@@ -79,6 +79,11 @@ declare namespace UniApp {
locale
:
string
fallbackLocale
:
string
locales
:
Record
<
string
,
Record
<
string
,
string
>>
compilerVersion
:
string
appId
:
string
appName
:
string
appVersion
:
string
appVersionCode
:
string
}
interface
UniRoute
{
...
...
packages/uni-app-plus/src/service/api/device/systemInfo.ts
浏览文件 @
0c59f2a4
...
...
@@ -5,6 +5,7 @@ import { getCurrentWebview } from '../../utils'
import
{
getStatusbarHeight
}
from
'
../../../helpers/statusBar
'
import
{
isTabBarPage
}
from
'
../../../helpers/plus
'
import
deviceId
from
'
../../../helpers/uuid
'
import
{
extend
}
from
'
@vue/shared
'
type
SafeAreaInsets
=
Required
<
PlusNavigatorSafeAreaInsets
>
...
...
@@ -24,9 +25,13 @@ function getScreenInfo() {
export
const
getSystemInfoSync
=
defineSyncApi
<
typeof
uni
.
getSystemInfoSync
>
(
'
getSystemInfoSync
'
,
()
=>
{
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
}
=
getScreenInfo
()
const
statusBarHeight
=
getStatusbarHeight
()
...
...
@@ -90,31 +95,38 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
height
:
windowHeightReal
-
safeAreaInsets
.
top
-
safeAreaInsets
.
bottom
,
}
return
{
brand
:
plus
.
device
.
vendor
!
,
model
:
plus
.
device
.
model
!
,
pixelRatio
:
plus
.
screen
.
scale
!
,
screenWidth
,
screenHeight
,
windowWidth
,
windowHeight
,
statusBarHeight
,
language
:
plus
.
os
.
language
!
,
system
:
`
${
ios
?
'
iOS
'
:
isAndroid
?
'
Android
'
:
''
}
${
plus
.
os
.
version
!
}
`
,
version
:
plus
.
runtime
.
innerVersion
!
,
platform
,
SDKVersion
:
''
,
windowTop
,
windowBottom
,
safeArea
,
safeAreaInsets
:
{
top
:
safeAreaInsets
.
top
,
right
:
safeAreaInsets
.
right
,
bottom
:
safeAreaInsets
.
bottom
,
left
:
safeAreaInsets
.
left
,
return
extend
(
{
brand
:
brand
,
model
:
deviceModel
,
pixelRatio
:
plus
.
screen
.
scale
!
,
screenWidth
,
screenHeight
,
windowWidth
,
windowHeight
,
statusBarHeight
,
language
:
osLanguage
,
system
:
`
${
osName
}
${
osVersion
}
`
,
version
:
plus
.
runtime
.
innerVersion
!
,
platform
:
_osName
,
SDKVersion
:
''
,
windowTop
,
windowBottom
,
safeArea
,
safeAreaInsets
:
{
top
:
safeAreaInsets
.
top
,
right
:
safeAreaInsets
.
right
,
bottom
:
safeAreaInsets
.
bottom
,
left
:
safeAreaInsets
.
left
,
},
deviceId
:
deviceId
(),
},
deviceId
:
deviceId
(),
}
info
,
{
deviceBrand
:
brand
,
osName
:
_osName
,
}
)
}
)
...
...
packages/uni-cli-shared/src/env/define.ts
浏览文件 @
0c59f2a4
...
...
@@ -14,6 +14,12 @@ export function initDefine(stringifyBoolean: boolean = false) {
:
isDebug
,
'
process.env.UNI_APP_ID
'
:
JSON
.
stringify
(
manifestJson
.
appid
||
''
),
'
process.env.UNI_APP_NAME
'
:
JSON
.
stringify
(
manifestJson
.
name
||
''
),
'
process.env.UNI_APP_VERSION_NAME
'
:
JSON
.
stringify
(
manifestJson
.
versionName
||
''
),
'
process.env.UNI_APP_VERSION_CODE
'
:
JSON
.
stringify
(
manifestJson
.
versionCode
||
''
),
'
process.env.UNI_PLATFORM
'
:
JSON
.
stringify
(
process
.
env
.
UNI_PLATFORM
),
'
process.env.UNI_MP_PLUGIN
'
:
JSON
.
stringify
(
process
.
env
.
UNI_MP_PLUGIN
),
'
process.env.UNI_SUBPACKAGE
'
:
JSON
.
stringify
(
process
.
env
.
UNI_SUBPACKAGE
),
...
...
packages/uni-h5-vite/src/plugins/pagesJson.ts
浏览文件 @
0c59f2a4
...
...
@@ -247,6 +247,13 @@ function generateConfig(
pagesJson
:
Record
<
string
,
any
>
,
config
:
ResolvedConfig
)
{
const
extraParameters
=
{
appId
:
process
.
env
.
UNI_APP_ID
,
appName
:
process
.
env
.
UNI_APP_NAME
,
appVersion
:
process
.
env
.
UNI_APP_VERSION
,
appVersionCode
:
process
.
env
.
UNI_APP_VERSION_CODE
,
}
delete
pagesJson
.
pages
delete
pagesJson
.
subPackages
delete
pagesJson
.
subpackages
...
...
@@ -257,7 +264,9 @@ function generateConfig(
:
`
${
globalName
}
['____'+appid+'____']=true
delete
${
globalName
}
['____'+appid+'____']
`
)
+
`
${
globalName
}
.__uniConfig=extend(
${
JSON
.
stringify
(
pagesJson
)}
,{
`
${
globalName
}
.__uniConfig=extend(
${
JSON
.
stringify
(
extraParameters
)}
,
${
JSON
.
stringify
(
pagesJson
)}
,{
async,
debug,
networkTimeout,
...
...
packages/uni-h5/src/service/api/device/getSystemInfoSync.ts
浏览文件 @
0c59f2a4
...
...
@@ -3,6 +3,7 @@ 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
,
...
...
@@ -47,6 +48,7 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
let
osname
let
osversion
let
model
=
''
let
deviceType
=
'
phone
'
if
(
isIOS
)
{
osname
=
'
iOS
'
...
...
@@ -101,10 +103,12 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
}
else
if
(
isIPadOS
)
{
model
=
'
iPad
'
osname
=
'
iOS
'
deviceType
=
'
pad
'
osversion
=
typeof
window
.
BigInt
===
'
function
'
?
'
14.0
'
:
'
13.0
'
}
else
if
(
isWindows
||
isMac
||
isLinux
)
{
model
=
'
PC
'
osname
=
'
PC
'
deviceType
=
'
pc
'
osversion
=
'
0
'
let
osversionFind
=
ua
.
match
(
/
\((
.+
?)\)
/
)
!
[
1
]
...
...
@@ -164,6 +168,7 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
}
else
{
osname
=
'
Other
'
osversion
=
'
0
'
deviceType
=
'
other
'
}
const
system
=
`
${
osname
}
${
osversion
}
`
...
...
@@ -182,6 +187,33 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.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
,
...
...
@@ -202,9 +234,25 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
bottom
:
safeAreaInsets
.
bottom
,
left
:
safeAreaInsets
.
left
,
},
version
:
''
,
version
:
__uniConfig
.
appVersion
,
SDKVersion
:
''
,
deviceId
:
deviceId
(),
ua
,
uniPlatform
:
'
web
'
,
browserName
,
browseVersion
,
osLanguage
:
language
,
osName
:
osname
,
osVersion
:
osversion
,
hostLanguage
:
language
,
uniCompileVersion
:
__uniConfig
.
compilerVersion
,
uniRuntimeVersion
:
__uniConfig
.
compilerVersion
,
appId
:
__uniConfig
.
appId
,
appName
:
__uniConfig
.
appName
,
appVersion
:
__uniConfig
.
appVersion
,
appVersionCode
:
__uniConfig
.
appVersionCode
,
osTheme
:
''
,
hostTheme
:
''
,
}
}
)
packages/uni-mp-alipay/src/api/protocols.ts
浏览文件 @
0c59f2a4
import
{
isPlainObject
,
isArray
,
hasOwn
}
from
'
@vue/shared
'
import
{
addSafeAreaInsets
,
useDeviceId
}
from
'
@dcloudio/uni-mp-core
'
import
{
addSafeAreaInsets
,
useDeviceId
,
populateParameters
,
}
from
'
@dcloudio/uni-mp-core
'
import
{
getStorageSync
}
from
'
./shims
'
...
...
@@ -33,6 +37,7 @@ function handleSystemInfo(
useDeviceId
({
getStorageSync
,
})(
fromRes
,
toRes
)
populateParameters
(
fromRes
,
toRes
)
let
platform
=
fromRes
.
platform
?
fromRes
.
platform
.
toLowerCase
()
:
'
devtools
'
if
(
!~
[
'
android
'
,
'
ios
'
].
indexOf
(
platform
))
{
...
...
packages/uni-mp-core/src/api/protocols/addSafeAreaInsets.ts
已删除
100644 → 0
浏览文件 @
d4b24efc
export
function
addSafeAreaInsets
(
fromRes
:
any
,
toRes
:
UniApp
.
GetSystemInfoResult
)
{
if
(
fromRes
.
safeArea
)
{
const
safeArea
=
fromRes
.
safeArea
toRes
.
safeAreaInsets
=
{
top
:
safeArea
.
top
,
left
:
safeArea
.
left
,
right
:
fromRes
.
windowWidth
-
safeArea
.
right
,
bottom
:
Math
.
abs
(
fromRes
.
screenHeight
-
safeArea
.
bottom
),
}
}
}
packages/uni-mp-core/src/api/protocols/enhanceSystemInfo.ts
0 → 100644
浏览文件 @
0c59f2a4
import
{
getDeviceBrand
}
from
'
@dcloudio/uni-shared
'
const
UUID_KEY
=
'
__DC_STAT_UUID
'
let
deviceId
:
string
interface
Global
{
getStorageSync
:
UniApp
.
Uni
[
'
getStorageSync
'
]
}
export
function
useDeviceId
(
global
:
Global
=
__GLOBAL__
as
Global
)
{
return
function
addDeviceId
(
_
:
any
,
toRes
:
UniApp
.
GetSystemInfoResult
)
{
deviceId
=
deviceId
||
global
.
getStorageSync
(
UUID_KEY
)
if
(
!
deviceId
)
{
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
)
__GLOBAL__
.
setStorage
({
key
:
UUID_KEY
,
data
:
deviceId
,
})
}
toRes
.
deviceId
=
deviceId
}
}
export
function
addSafeAreaInsets
(
fromRes
:
any
,
toRes
:
UniApp
.
GetSystemInfoResult
)
{
if
(
fromRes
.
safeArea
)
{
const
safeArea
=
fromRes
.
safeArea
toRes
.
safeAreaInsets
=
{
top
:
safeArea
.
top
,
left
:
safeArea
.
left
,
right
:
fromRes
.
windowWidth
-
safeArea
.
right
,
bottom
:
fromRes
.
screenHeight
-
safeArea
.
bottom
,
}
}
}
export
function
populateParameters
(
fromRes
:
any
,
toRes
:
UniApp
.
GetSystemInfoResult
)
{
const
{
brand
,
model
,
system
,
language
,
theme
,
version
,
hostName
,
platform
}
=
fromRes
// 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
=
fromRes
.
swanNativeVersion
||
version
}
// deviceType
let
deviceType
=
fromRes
.
deviceType
||
'
phone
'
if
(
__PLATFORM__
!==
'
mp-baidu
'
)
{
type
DeviceTypeMapsKeys
=
keyof
typeof
deviceTypeMaps
const
deviceTypeMaps
=
{
ipad
:
'
pad
'
,
windows
:
'
pc
'
,
mac
:
'
pc
'
,
}
const
deviceTypeMapsKeys
=
Object
.
keys
(
deviceTypeMaps
)
as
DeviceTypeMapsKeys
[]
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
=
(
fromRes
.
host
||
{}).
env
if
(
__PLATFORM__
===
'
mp-baidu
'
||
__PLATFORM__
===
'
mp-kuaishou
'
)
_hostName
=
fromRes
.
host
if
(
__PLATFORM__
===
'
mp-qq
'
)
_hostName
=
fromRes
.
AppPlatform
if
(
__PLATFORM__
===
'
mp-toutiao
'
||
__PLATFORM__
===
'
mp-lark
'
)
_hostName
=
fromRes
.
appName
if
(
__PLATFORM__
===
'
mp-alipay
'
)
_hostName
=
fromRes
.
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
hostTheme
:
''
,
hostPackageName
:
''
,
browserName
:
''
,
browseVersion
:
''
,
}
Object
.
assign
(
toRes
,
parameters
)
}
packages/uni-mp-core/src/api/protocols/getSystemInfo.ts
浏览文件 @
0c59f2a4
import
{
addSafeAreaInsets
}
from
'
./addSafeAreaInsets
'
import
{
useDeviceId
}
from
'
./useDeviceId
'
import
{
useDeviceId
,
addSafeAreaInsets
,
populateParameters
,
}
from
'
./enhanceSystemInfo
'
import
{
MPProtocol
}
from
'
./types
'
export
const
getSystemInfo
:
MPProtocol
=
{
returnValue
:
(
fromRes
,
toRes
)
=>
{
addSafeAreaInsets
(
fromRes
,
toRes
)
useDeviceId
()(
fromRes
,
toRes
)
populateParameters
(
fromRes
,
toRes
)
},
}
packages/uni-mp-core/src/api/protocols/index.ts
浏览文件 @
0c59f2a4
export
{
addSafeAreaInsets
}
from
'
./addSafeAreaInsets
'
export
{
useDeviceId
}
from
'
./useDeviceId
'
export
{
useDeviceId
,
addSafeAreaInsets
,
populateParameters
,
}
from
'
./enhanceSystemInfo
'
export
{
getSystemInfo
}
from
'
./getSystemInfo
'
export
{
getSystemInfoSync
}
from
'
./getSystemInfoSync
'
export
{
redirectTo
}
from
'
./redirectTo
'
...
...
packages/uni-mp-core/src/api/protocols/useDeviceId.ts
已删除
100644 → 0
浏览文件 @
d4b24efc
const
UUID_KEY
=
'
__DC_STAT_UUID
'
let
deviceId
:
string
interface
Global
{
getStorageSync
:
UniApp
.
Uni
[
'
getStorageSync
'
]
}
export
function
useDeviceId
(
global
:
Global
=
__GLOBAL__
as
Global
)
{
return
function
addDeviceId
(
_
:
any
,
toRes
:
UniApp
.
GetSystemInfoResult
)
{
deviceId
=
deviceId
||
global
.
getStorageSync
(
UUID_KEY
)
if
(
!
deviceId
)
{
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
)
__GLOBAL__
.
setStorage
({
key
:
UUID_KEY
,
data
:
deviceId
,
})
}
toRes
.
deviceId
=
deviceId
}
}
packages/uni-mp-core/src/index.ts
浏览文件 @
0c59f2a4
...
...
@@ -52,6 +52,7 @@ export {
getSystemInfoSync
,
addSafeAreaInsets
,
useDeviceId
,
populateParameters
,
showActionSheet
,
}
from
'
./api/protocols
'
// types
...
...
packages/uni-mp-toutiao/src/api/protocols.ts
浏览文件 @
0c59f2a4
export
{
redirectTo
,
navigateTo
,
previewImage
}
from
'
@dcloudio/uni-mp-core
'
export
{
redirectTo
,
navigateTo
,
previewImage
,
getSystemInfo
,
getSystemInfoSync
,
}
from
'
@dcloudio/uni-mp-core
'
export
const
chooseImage
=
{
args
:
{
sizeType
:
false
,
...
...
packages/uni-shared/src/utils.ts
浏览文件 @
0c59f2a4
...
...
@@ -129,3 +129,37 @@ 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
'
}
}
packages/vite-plugin-uni/src/index.ts
浏览文件 @
0c59f2a4
...
...
@@ -11,6 +11,7 @@ import {
CopyOptions
,
initModuleAlias
,
initPreContext
,
parseManifestJsonOnce
,
}
from
'
@dcloudio/uni-cli-shared
'
import
{
createConfig
}
from
'
./config
'
...
...
@@ -33,6 +34,8 @@ const debugUni = debug('uni:plugin')
const
pkg
=
require
(
path
.
resolve
(
__dirname
,
'
../package.json
'
))
const
manifestJson
=
parseManifestJsonOnce
(
process
.
env
.
UNI_INPUT_DIR
)
initModuleAlias
()
rewriteCompilerSfcParse
()
...
...
@@ -42,6 +45,10 @@ process.env.UNI_COMPILER_VERSION_TYPE = pkg.version.includes('alpha')
?
'
a
'
:
'
r
'
process
.
env
.
UNI_APP_ID
=
manifestJson
.
appid
||
''
process
.
env
.
UNI_APP_NAME
=
manifestJson
.
name
||
''
process
.
env
.
UNI_APP_VERSION
=
manifestJson
.
versionName
||
''
process
.
env
.
UNI_APP_VERSION_CODE
=
manifestJson
.
versionCode
||
''
export
interface
VitePluginUniOptions
{
vueOptions
?:
VueOptions
vueJsxOptions
?:
(
VueJSXPluginOptions
&
{
babelPlugins
?:
any
[]
})
|
boolean
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录