Files
ys-app/src/utils/system.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2025-07-22 11:21:01 +08:00
// 旧版
// const SYSTEM_INFO = uni.getSystemInfoSync();
const SYSTEM_INFO = uni.getWindowInfo();
// 获取状态栏高度
// const systemInfo = uni.getSystemInfoSync()
// statusBarHeight.value = systemInfo.statusBarHeight || 0
// 计算导航栏总高度 (状态栏 + 导航栏)
// 通常导航栏高度在H5中是44px小程序中是48px
// const platform = systemInfo.platform
// navbarHeight.value = statusBarHeight.value + (platform === 'ios' ? 44 : 48)
//时间电量状态栏高度
export const getStatusBarHeight = ()=> SYSTEM_INFO.statusBarHeight;
export const getTitleBarHeight = ()=>{
//关闭按钮胶囊
if(uni.getMenuButtonBoundingClientRect){
let {top,height} = uni.getMenuButtonBoundingClientRect();
return height + (top - getStatusBarHeight())*2
}else{
return 0;
}
}
export const getNavBarHeight = () => getStatusBarHeight()+getTitleBarHeight();
export const getNavBarPaddingTop = () => {
let h=0;
if(uni.getMenuButtonBoundingClientRect){
let {top,height} = uni.getMenuButtonBoundingClientRect();
h = height + (top - getStatusBarHeight());
}else{
// #ifdef APP-PLUS
h=22
// #endif
// #ifndef APP-PLUS
h=0
// #endif
}
2025-08-11 17:30:44 +08:00
// console.log("h=>",h)
2025-07-22 11:21:01 +08:00
return h;
}