
1 changed files with 83 additions and 84 deletions
@ -1,85 +1,84 @@ |
|||||
function navParams() { |
function navParams() { |
||||
|
|
||||
let params = { |
let params = { |
||||
// 是否支持自定义导航栏(小程序 pc版 false)
|
// 是否支持自定义导航栏(小程序 pc版 false)
|
||||
supportCustomBar: true, |
supportCustomBar: true, |
||||
// 胶囊
|
// 胶囊
|
||||
menuButton: { |
menuButton: { |
||||
width: 0, |
width: 0, |
||||
height: 0 |
height: 0 |
||||
}, |
}, |
||||
// 导航栏
|
// 导航栏
|
||||
// 可自定义,wx小程序会强制更改
|
// 可自定义,wx小程序会强制更改
|
||||
navBar: { |
navBar: { |
||||
height: 0, |
height: 0, |
||||
// 导航栏字体大小 wx小程序 ios:13,Android:17
|
// 导航栏字体大小 wx小程序 ios:13,Android:17
|
||||
fontSize: 0, |
fontSize: 0, |
||||
// 导航栏样式 wx小程序时:ios:center,Android:left
|
// 导航栏样式 wx小程序时:ios:center,Android:left
|
||||
style: '', |
style: '', |
||||
// 导航栏可用宽度 wx小程序时 ios,Android:屏幕宽-胶囊
|
// 导航栏可用宽度 wx小程序时 ios,Android:屏幕宽-胶囊
|
||||
enableWidth: 0, |
enableWidth: 0, |
||||
// 导航栏不可用宽度 wx小程序时 ios,Android:胶囊+胶囊距离屏幕右侧边界的距离
|
// 导航栏不可用宽度 wx小程序时 ios,Android:胶囊+胶囊距离屏幕右侧边界的距离
|
||||
disableWidth: 0 |
disableWidth: 0 |
||||
}, |
}, |
||||
window: { |
window: { |
||||
width: 0, |
width: 0, |
||||
height: 0 |
height: 0 |
||||
}, |
}, |
||||
os: { |
os: { |
||||
osName: '' |
osName: '' |
||||
}, |
}, |
||||
// 导航栏+状态栏高度
|
// 导航栏+状态栏高度
|
||||
navStatusHeight: '0px', |
navStatusHeight: '0px', |
||||
// 状态栏高度
|
// 状态栏高度
|
||||
statusBarHeight: 0, |
statusBarHeight: 0, |
||||
unit: 'px' |
unit: 'px' |
||||
} |
} |
||||
|
|
||||
// 同步获取信息
|
// 同步获取信息
|
||||
let info = uni.getSystemInfoSync(); |
let info = uni.getSystemInfoSync(); |
||||
|
|
||||
// 状态栏高度
|
// 状态栏高度
|
||||
params.statusBarHeight = info.statusBarHeight; |
params.statusBarHeight = info.statusBarHeight; |
||||
params.window.width = info.screenWidth |
params.window.width = info.screenWidth |
||||
params.window.height = info.screenHeight |
params.window.height = info.screenHeight |
||||
params.os.osName = info.osName |
params.os.osName = info.osName |
||||
|
|
||||
// 获取胶囊相关内容
|
// 获取胶囊相关内容
|
||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||
let menuButton = uni.getMenuButtonBoundingClientRect(); |
let menuButton = uni.getMenuButtonBoundingClientRect(); |
||||
params.menuButton.width = menuButton.width; |
params.menuButton.width = menuButton.width; |
||||
params.menuButton.height = menuButton.height; |
params.menuButton.height = menuButton.height; |
||||
let paddingTop = menuButton.top - params.statusBarHeight; |
let paddingTop = menuButton.top - params.statusBarHeight; |
||||
let paddingBottom = 0; |
let paddingBottom = 0; |
||||
if (params.os.osName === 'ios') { |
if (params.os.osName === 'ios') { |
||||
paddingBottom = paddingTop * 2; |
paddingBottom = paddingTop * 2; |
||||
params.navBar.fontSize = 13; |
params.navBar.fontSize = 13; |
||||
params.navBar.style = 'center'; |
params.navBar.style = 'center'; |
||||
} else if (params.os.osName === 'android') { |
} else if (params.os.osName === 'android') { |
||||
paddingBottom = paddingTop; |
paddingBottom = paddingTop; |
||||
params.navBar.fontSize = 17; |
params.navBar.fontSize = 17; |
||||
params.navBar.style = 'left'; |
params.navBar.style = 'left'; |
||||
} else if (params.os.osName === 'windows') { |
} else if (params.os.osName === 'windows' || params.os.osName === 'mac') { |
||||
params.supportCustomBar = false; |
params.supportCustomBar = false; |
||||
} else { |
} else { |
||||
// 未测试
|
// 未知系统按照Android处理
|
||||
paddingBottom = paddingTop; |
paddingBottom = paddingTop; |
||||
params.navBar.fontSize = 17; |
params.navBar.fontSize = 17; |
||||
params.navBar.style = 'left'; |
params.navBar.style = 'left'; |
||||
// macos 未测试
|
} |
||||
} |
params.navBar.height = params.menuButton.height + paddingTop + paddingBottom; |
||||
params.navBar.height = params.menuButton.height + paddingTop + paddingBottom; |
// 导航栏可用宽度 屏幕左边界到胶囊左边界
|
||||
// 导航栏可用宽度 屏幕左边界到胶囊左边界
|
params.navBar.enableWidth = menuButton.left; |
||||
params.navBar.enableWidth = menuButton.left; |
params.navBar.disableWidth = params.window.width - params.navBar.enableWidth; |
||||
params.navBar.disableWidth = params.window.width - params.navBar.enableWidth; |
// #endif
|
||||
// #endif
|
|
||||
|
params.navStatusHeight = params.statusBarHeight + params.navBar.height |
||||
params.navStatusHeight = params.statusBarHeight + params.navBar.height |
|
||||
|
console.log(params); |
||||
console.log(params); |
return params |
||||
return params |
} |
||||
} |
|
||||
|
export { |
||||
export { |
navParams |
||||
navParams |
|
||||
} |
} |
Loading…
Reference in new issue