59e51671
“wangming”
1
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
let _statusBarHeight: number | null = null
let _bottomSafeArea: number | null = null
export function getStatusBarHeight(): number {
if (_statusBarHeight === null) {
_initSafeArea()
}
return _statusBarHeight || 0
}
export function getBottomSafeArea(): number {
if (_bottomSafeArea === null) {
_initSafeArea()
}
return _bottomSafeArea || 0
}
function _initSafeArea() {
try {
const info = uni.getSystemInfoSync()
_statusBarHeight = info.statusBarHeight || 0
if (info.safeArea && info.screenHeight) {
_bottomSafeArea = info.screenHeight - info.safeArea.bottom
} else {
_bottomSafeArea = 0
}
} catch (e) {
_statusBarHeight = 0
_bottomSafeArea = 0
}
}
|