页面优化

This commit is contained in:
Dev
2026-10-19 15:46:10 +08:00
parent 44405743bb
commit 6beeeb2383
14 changed files with 229 additions and 120 deletions
+4 -16
View File
@@ -56,26 +56,14 @@ App({
bindPendingPromoter();
}
updateManager();
//从后台切回前台时刷新一次未读红点(不使用定时轮询,避免请求堆积导致页面卡死)
this.refreshUnread();
// 切回前台的时间。Tab 页用它区分「从后台回来」和「切换 Tab」,避免每次 onShow 都打接口
this.globalData.appShowAt = Date.now();
},
onHide: function () {},
globalData: {
unread: 0, //未读消息数(tabbar红点共享缓存)
unreadFetchedAt: 0, //上次拉取未读数的时间,各 tabBar 实例共用,避免切 Tab 重复请求
appShowAt: 0, //最近一次 App.onShow 的时间
refreshDemandId: 0, //操作后需要刷新状态的需求ID(跨页面通知列表页)
},
/**
* 刷新当前 tab 页 tabbar 实例的红点(非tab页无tabbar实例,自动跳过)
*/
refreshUnread: function () {
if (!wx.getStorageSync('token')) {
return;
}
const page = getCurrentPages().pop();
const tabBar = page && typeof page.getTabBar === 'function' ? page.getTabBar() : null;
if (tabBar && typeof tabBar.refreshUnread === 'function') {
tabBar.refreshUnread();
}
},
});