const { BASE_URL } = require('./config'); App({ globalData: { // 状态栏高度(px),由 onLaunch 读取,供自定义导航栏计算顶部留白 statusBarHeight: 20, // 后端基础地址 baseUrl: BASE_URL }, onLaunch() { // 读取窗口信息以获取状态栏高度(兼容新旧 API) try { const info = (typeof wx.getWindowInfo === 'function') ? wx.getWindowInfo() : wx.getSystemInfoSync(); this.globalData.statusBarHeight = info.statusBarHeight || 20; } catch (e) { this.globalData.statusBarHeight = 20; } // 可选:静默登录(占位,不请求真实后端) // const { getOpenid } = require('./utils/auth'); // getOpenid(); } });