Files
2026-10-26 17:32:47 +08:00

17 lines
796 B
JavaScript

// 只计算设备布局,不保存接口数据。
function getLayout() {
var info = {};
try { info = wx.getWindowInfo ? wx.getWindowInfo() : wx.getSystemInfoSync(); } catch (e) {}
var status = info.statusBarHeight || 20;
var capsule;
try { capsule = wx.getMenuButtonBoundingClientRect(); } catch (e) {}
var bar = capsule && capsule.height > 0 && capsule.top >= status
? capsule.height + (capsule.top - status) * 2 : 44;
var height = status + bar;
var width = info.windowWidth || 375;
var side = capsule && capsule.left > width / 2 ? width - capsule.left + 12 : 100;
return { statusBarHeight: status, barHeight: bar, navHeight: height, navSide: side,
layoutStyle: '--nav-height:' + height + 'px;--status-height:' + status + 'px;' };
}
module.exports = { getLayout };