Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
3a9ad945
U
uni-app
项目概览
DCloud
/
uni-app
2 个月 前同步成功
通知
717
Star
38705
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3a9ad945
编写于
8月 22, 2019
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: uni.getSystemInfo 增加 safeArea 属性支持(app-plus)
上级
612dc687
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
8 deletion
+30
-8
src/platforms/app-plus/service/api/device/system.js
src/platforms/app-plus/service/api/device/system.js
+30
-8
未找到文件。
src/platforms/app-plus/service/api/device/system.js
浏览文件 @
3a9ad945
...
...
@@ -23,10 +23,19 @@ export function getSystemInfo () {
const
screenHeight
=
plus
.
screen
.
resolutionHeight
// 横屏时 iOS 获取的状态栏高度错误,进行纠正
var
landscape
=
Math
.
abs
(
plus
.
navigator
.
getOrientation
())
===
90
var
statusBarHeight
=
plus
.
navigator
.
getStatusbarHeight
(
)
var
statusBarHeight
=
Math
.
round
(
plus
.
navigator
.
getStatusbarHeight
()
)
if
(
ios
&&
landscape
)
{
statusBarHeight
=
Math
.
min
(
20
,
statusBarHeight
)
}
var
safeAreaInsets
function
getSafeAreaInsets
()
{
return
{
left
:
0
,
right
:
0
,
top
:
titleNView
?
0
:
statusBarHeight
,
bottom
:
0
}
}
// 判断是否存在 titleNView
var
titleNView
var
webview
=
getLastWebview
()
...
...
@@ -36,7 +45,22 @@ export function getSystemInfo () {
titleNView
=
style
&&
style
.
titleNView
titleNView
=
titleNView
&&
titleNView
.
type
===
'
default
'
}
safeAreaInsets
=
ios
?
webview
.
getSafeAreaInsets
()
:
getSafeAreaInsets
()
}
else
{
safeAreaInsets
=
ios
?
plus
.
navigator
.
getSafeAreaInsets
()
:
getSafeAreaInsets
()
}
var
windowHeight
=
Math
.
min
(
screenHeight
-
(
titleNView
?
(
statusBarHeight
+
TITLEBAR_HEIGHT
)
:
0
)
-
(
isTabBarPage
()
&&
tabBar
.
visible
?
TABBAR_HEIGHT
:
0
),
screenHeight
)
var
windowWidth
=
screenWidth
var
safeArea
=
{
left
:
safeAreaInsets
.
left
,
right
:
windowWidth
-
safeAreaInsets
.
right
,
top
:
safeAreaInsets
.
top
,
bottom
:
windowHeight
-
safeAreaInsets
.
bottom
,
width
:
windowWidth
-
safeAreaInsets
.
left
-
safeAreaInsets
.
right
,
height
:
windowHeight
-
safeAreaInsets
.
top
-
safeAreaInsets
.
bottom
}
return
{
errMsg
:
'
getSystemInfo:ok
'
,
brand
:
''
,
...
...
@@ -44,11 +68,8 @@ export function getSystemInfo () {
pixelRatio
:
plus
.
screen
.
scale
,
screenWidth
,
screenHeight
,
// 安卓端 webview 宽度有时比屏幕多 1px,相比取最小值
// TODO screenWidth,screenHeight
windowWidth
:
screenWidth
,
windowHeight
:
Math
.
min
(
screenHeight
-
(
titleNView
?
(
statusBarHeight
+
TITLEBAR_HEIGHT
)
:
0
)
-
(
isTabBarPage
()
&&
tabBar
.
visible
?
TABBAR_HEIGHT
:
0
),
screenHeight
),
windowWidth
,
windowHeight
,
statusBarHeight
,
language
:
plus
.
os
.
language
,
system
:
plus
.
os
.
version
,
...
...
@@ -57,6 +78,7 @@ export function getSystemInfo () {
platform
,
SDKVersion
:
''
,
windowTop
:
0
,
windowBottom
:
0
windowBottom
:
0
,
safeArea
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录