/** * 系统与窗口信息工具 * 兼容微信小程序新版规范(废弃 wx.getSystemInfoSync,推荐 getWindowInfo) */ export function getWindowInfoSafe() { try { if (typeof uni.getWindowInfo === 'function') { const win = uni.getWindowInfo(); if (win && (win.statusBarHeight !== undefined || win.windowWidth !== undefined)) { return win; } } if (typeof uni.getSystemInfoSync === 'function') { return uni.getSystemInfoSync(); } } catch (e) { // 忽略异常,降级兜底 } return { statusBarHeight: 20, windowWidth: 375, windowHeight: 667, screenWidth: 375, screenHeight: 667 }; } export default { getWindowInfoSafe };