Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
erosXXX
uni-app
提交
1a03411b
U
uni-app
项目概览
erosXXX
/
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,体验更适合开发者的 AI 搜索 >>
提交
1a03411b
编写于
5月 27, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mp-weixin): getDeviceInfo、getAppBaseInfo、getWindowInfo
上级
bfa6eb46
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
108 addition
and
31 deletion
+108
-31
src/platforms/app-plus/service/api/device/system.js
src/platforms/app-plus/service/api/device/system.js
+2
-2
src/platforms/mp-weixin/helpers/enhance-system-info.js
src/platforms/mp-weixin/helpers/enhance-system-info.js
+47
-28
src/platforms/mp-weixin/helpers/get-app-base-info.js
src/platforms/mp-weixin/helpers/get-app-base-info.js
+24
-0
src/platforms/mp-weixin/helpers/get-device-info.js
src/platforms/mp-weixin/helpers/get-device-info.js
+16
-0
src/platforms/mp-weixin/helpers/get-window-info.js
src/platforms/mp-weixin/helpers/get-window-info.js
+12
-0
src/platforms/mp-weixin/runtime/api/protocols.js
src/platforms/mp-weixin/runtime/api/protocols.js
+7
-1
未找到文件。
src/platforms/app-plus/service/api/device/system.js
浏览文件 @
1a03411b
...
...
@@ -41,7 +41,7 @@ export function getDeviceInfo () {
export
function
getAppBaseInfo
()
{
weexGetSystemInfoSync
()
const
{
hostPackageName
,
hostName
,
osLanguage
,
hostPackageName
,
hostName
,
hostVersion
,
hostLanguage
,
hostTheme
,
appId
,
appName
,
appVersion
,
appVersionCode
}
=
systemInfo
...
...
@@ -56,7 +56,7 @@ export function getAppBaseInfo () {
appVersionCode
,
appLanguage
:
uni
.
getLocale
(),
version
:
plus
.
runtime
.
innerVersion
,
language
:
os
Language
,
language
:
host
Language
,
theme
:
''
,
hostPackageName
,
hostName
,
...
...
src/platforms/mp-weixin/helpers/enhance-system-info.js
浏览文件 @
1a03411b
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
'
let
deviceId
export
function
useDeviceId
(
result
)
{
export
function
useDeviceId
(
result
)
{
deviceId
=
deviceId
||
__GLOBAL__
.
getStorageSync
(
UUID_KEY
)
if
(
!
deviceId
)
{
deviceId
=
Date
.
now
()
+
''
+
Math
.
floor
(
Math
.
random
()
*
1
e7
)
...
...
@@ -17,7 +18,7 @@ export function useDeviceId (result) {
result
.
deviceId
=
deviceId
}
export
function
addSafeAreaInsets
(
result
)
{
export
function
addSafeAreaInsets
(
result
)
{
if
(
result
.
safeArea
)
{
const
safeArea
=
result
.
safeArea
result
.
safeAreaInsets
=
{
...
...
@@ -29,7 +30,7 @@ export function addSafeAreaInsets (result) {
}
}
export
function
populateParameters
(
result
)
{
export
function
populateParameters
(
result
)
{
const
{
brand
,
model
,
system
,
language
,
theme
,
version
,
...
...
@@ -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
}
}
}
let
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
)
}
let
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
&&
fromRes
.
host
.
env
)
{
_hostName
=
result
.
host
.
env
}
}
...
...
@@ -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
}
\ No newline at end of file
src/platforms/mp-weixin/helpers/get-app-base-info.js
0 → 100644
浏览文件 @
1a03411b
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
,
})
}
}
src/platforms/mp-weixin/helpers/get-device-info.js
0 → 100644
浏览文件 @
1a03411b
import
{
useDeviceId
,
getGetDeviceType
,
getDeviceBrand
}
from
'
./enhance-system-info
'
;
export
default
{
returnValue
:
function
(
result
)
{
const
{
brand
,
model
}
=
result
let
deviceType
=
getGetDeviceType
(
result
,
model
)
let
deviceBrand
=
getDeviceBrand
(
brand
,
model
)
useDeviceId
(
result
)
Object
.
assign
(
result
,
{
deviceType
,
deviceBrand
,
deviceModel
:
model
,
})
}
}
src/platforms/mp-weixin/helpers/get-window-info.js
0 → 100644
浏览文件 @
1a03411b
import
{
addSafeAreaInsets
}
from
'
./enhance-system-info
'
;
export
default
{
returnValue
:
function
(
result
)
{
addSafeAreaInsets
(
result
)
Object
.
assign
(
result
,
{
windowTop
:
0
,
windowBottom
:
0
,
})
}
}
src/platforms/mp-weixin/runtime/api/protocols.js
浏览文件 @
1a03411b
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录