Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
菜鸟程序猿_c
uni-app
提交
3928facf
U
uni-app
项目概览
菜鸟程序猿_c
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3928facf
编写于
5月 27, 2022
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mp-weixin): getDeviceInfo、getAppBaseInfo、getWindowInfo
上级
35bdc362
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
123 addition
and
35 deletion
+123
-35
packages/uni-app-plus/src/service/api/device/systemInfo.ts
packages/uni-app-plus/src/service/api/device/systemInfo.ts
+1
-2
packages/uni-mp-core/src/api/promise.ts
packages/uni-mp-core/src/api/promise.ts
+1
-1
packages/uni-mp-core/src/api/protocols/enhanceSystemInfo.ts
packages/uni-mp-core/src/api/protocols/enhanceSystemInfo.ts
+49
-32
packages/uni-mp-core/src/api/protocols/getAppBaseInfo.ts
packages/uni-mp-core/src/api/protocols/getAppBaseInfo.ts
+27
-0
packages/uni-mp-core/src/api/protocols/getDeviceInfo.ts
packages/uni-mp-core/src/api/protocols/getDeviceInfo.ts
+22
-0
packages/uni-mp-core/src/api/protocols/getWindowInfo.ts
packages/uni-mp-core/src/api/protocols/getWindowInfo.ts
+14
-0
packages/uni-mp-core/src/api/protocols/index.ts
packages/uni-mp-core/src/api/protocols/index.ts
+3
-0
packages/uni-mp-core/src/index.ts
packages/uni-mp-core/src/index.ts
+3
-0
packages/uni-mp-weixin/src/api/protocols.ts
packages/uni-mp-weixin/src/api/protocols.ts
+3
-0
未找到文件。
packages/uni-app-plus/src/service/api/device/systemInfo.ts
浏览文件 @
3928facf
...
...
@@ -49,7 +49,6 @@ export const getAppBaseInfo = defineSyncApi<typeof uni.getAppBaseInfo>(
const
{
hostPackageName
,
hostName
,
osLanguage
,
hostVersion
,
hostLanguage
,
hostTheme
,
...
...
@@ -69,7 +68,7 @@ export const getAppBaseInfo = defineSyncApi<typeof uni.getAppBaseInfo>(
appVersionCode
,
appLanguage
:
uni
.
getLocale
(),
version
:
plus
.
runtime
.
innerVersion
!
,
language
:
os
Language
,
language
:
host
Language
,
theme
:
''
,
hostPackageName
,
hostName
,
...
...
packages/uni-mp-core/src/api/promise.ts
浏览文件 @
3928facf
...
...
@@ -7,7 +7,7 @@ import {
}
from
'
@dcloudio/uni-api/src/helpers/interceptor
'
const
SYNC_API_RE
=
/^
\$
|getLocale|setLocale|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/
/^
\$
|getLocale|setLocale|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64
|getDeviceInfo|getAppBaseInfo|getWindowInfo
/
const
CONTEXT_API_RE
=
/^create|Manager$/
...
...
packages/uni-mp-core/src/api/protocols/enhanceSystemInfo.ts
浏览文件 @
3928facf
import
{
extend
}
from
'
@vue/shared
'
function
getDeviceBrand
(
model
:
string
)
{
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
'
}
return
''
}
const
UUID_KEY
=
'
__DC_STAT_UUID
'
...
...
@@ -84,45 +85,17 @@ export function populateParameters(
}
// 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
}
}
}
let
deviceType
=
getGetDeviceType
(
fromRes
,
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
(
fromRes
.
host
)
{
}
else
if
(
fromRes
.
host
&&
fromRes
.
host
.
env
)
{
_hostName
=
fromRes
.
host
.
env
}
}
...
...
@@ -189,3 +162,47 @@ export function populateParameters(
extend
(
toRes
,
parameters
)
}
export
function
getGetDeviceType
(
fromRes
:
any
,
model
:
string
)
{
// 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
}
}
}
return
deviceType
}
export
function
getDeviceBrand
(
brand
:
string
,
model
:
string
,
isQuickApp
:
boolean
=
false
)
{
// deviceModel
let
deviceBrand
=
model
.
split
(
'
'
)[
0
].
toLocaleLowerCase
()
if
(
__PLATFORM__
===
'
mp-toutiao
'
||
__PLATFORM__
===
'
mp-lark
'
||
isQuickApp
)
{
deviceBrand
=
brand
.
toLocaleLowerCase
()
}
else
{
deviceBrand
=
_getDeviceBrand
(
deviceBrand
)
}
return
deviceBrand
}
packages/uni-mp-core/src/api/protocols/getAppBaseInfo.ts
0 → 100644
浏览文件 @
3928facf
import
{
MPProtocol
}
from
'
./types
'
import
{
extend
}
from
'
@vue/shared
'
export
const
getAppBaseInfo
:
MPProtocol
=
{
returnValue
:
(
fromRes
,
toRes
)
=>
{
const
{
version
,
language
,
SDKVersion
,
theme
}
=
fromRes
let
_hostName
=
__PLATFORM__
.
split
(
'
-
'
)[
1
]
// mp-jd
if
(
__PLATFORM__
===
'
mp-weixin
'
)
{
if
(
fromRes
.
host
&&
fromRes
.
host
.
env
)
{
_hostName
=
fromRes
.
host
.
env
}
}
extend
(
toRes
,
{
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
,
})
},
}
packages/uni-mp-core/src/api/protocols/getDeviceInfo.ts
0 → 100644
浏览文件 @
3928facf
import
{
MPProtocol
}
from
'
./types
'
import
{
getGetDeviceType
,
getDeviceBrand
,
useDeviceId
,
}
from
'
./enhanceSystemInfo
'
import
{
extend
}
from
'
@vue/shared
'
export
const
getDeviceInfo
:
MPProtocol
=
{
returnValue
:
(
fromRes
,
toRes
)
=>
{
const
{
brand
,
model
}
=
fromRes
let
deviceType
=
getGetDeviceType
(
fromRes
,
model
)
let
deviceBrand
=
getDeviceBrand
(
brand
,
model
)
useDeviceId
()(
fromRes
,
toRes
)
extend
(
toRes
,
{
deviceType
,
deviceBrand
,
deviceModel
:
model
,
})
},
}
packages/uni-mp-core/src/api/protocols/getWindowInfo.ts
0 → 100644
浏览文件 @
3928facf
import
{
MPProtocol
}
from
'
./types
'
import
{
extend
}
from
'
@vue/shared
'
import
{
addSafeAreaInsets
}
from
'
./enhanceSystemInfo
'
export
const
getWindowInfo
:
MPProtocol
=
{
returnValue
:
(
fromRes
,
toRes
)
=>
{
addSafeAreaInsets
(
fromRes
,
toRes
)
extend
(
toRes
,
{
windowTop
:
0
,
windowBottom
:
0
,
})
},
}
packages/uni-mp-core/src/api/protocols/index.ts
浏览文件 @
3928facf
...
...
@@ -9,4 +9,7 @@ export { redirectTo } from './redirectTo'
export
{
previewImage
}
from
'
./previewImage
'
export
{
showActionSheet
}
from
'
./showActionSheet
'
export
{
navigateTo
,
initEventChannel
,
getEventChannel
}
from
'
./navigateTo
'
export
{
getDeviceInfo
}
from
'
./getDeviceInfo
'
export
{
getAppBaseInfo
}
from
'
./getAppBaseInfo
'
export
{
getWindowInfo
}
from
'
./getWindowInfo
'
export
*
from
'
./types
'
packages/uni-mp-core/src/index.ts
浏览文件 @
3928facf
...
...
@@ -54,6 +54,9 @@ export {
useDeviceId
,
populateParameters
,
showActionSheet
,
getDeviceInfo
,
getAppBaseInfo
,
getWindowInfo
,
}
from
'
./api/protocols
'
// types
export
{
MiniProgramAppOptions
,
MiniProgramAppInstance
}
from
'
./runtime/app
'
...
...
packages/uni-mp-weixin/src/api/protocols.ts
浏览文件 @
3928facf
...
...
@@ -4,4 +4,7 @@ export {
getSystemInfo
,
getSystemInfoSync
,
showActionSheet
,
getDeviceInfo
,
getAppBaseInfo
,
getWindowInfo
,
}
from
'
@dcloudio/uni-mp-core
'
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录