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 } }