Files
ys-app/src/utils/system.js
2025-07-22 11:21:01 +08:00

45 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 旧版
// 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
}
console.log("h=>",h)
return h;
}