Merge branch 'bug-profile' into feature-3.0.0

This commit is contained in:
R524809
2026-05-25 16:26:38 +08:00
6 changed files with 41 additions and 8 deletions
+32 -2
View File
@@ -1,2 +1,32 @@
/** 与 style/theme.less 中 @nav-inner-height 对齐(px */
export const NAV_INNER_PX = 44;
/**
* 导航栏内容区高度(px)。
* 基于胶囊按钮位置计算:让 inner 的垂直中心与胶囊中心对齐,
* inner_height = (capsule.top - statusBarHeight) * 2 + capsule.height。
* 默认值 44 仅作兜底。
*/
let cachedInnerPx: number | null = null;
function computeInnerPx(): number {
try {
const { statusBarHeight } = wx.getWindowInfo();
const rect = wx.getMenuButtonBoundingClientRect();
const inner = (rect.top - statusBarHeight) * 2 + rect.height;
if (inner > 0 && Number.isFinite(inner)) {
return Math.round(inner);
}
} catch (e) {
// ignore, fallback below
}
return 44;
}
export function getNavInnerPx(): number {
if (cachedInnerPx === null) {
cachedInnerPx = computeInnerPx();
}
return cachedInnerPx;
}
/** 兼容旧调用:保留常量导出,启动时取一次胶囊几何。 */
export const NAV_INNER_PX = getNavInnerPx();