restore: 恢复橙色逍遥梦UI版本(2ea2860)到主分支
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -32,6 +32,13 @@ const roleCfg = {
|
||||
},
|
||||
};
|
||||
|
||||
const TAB_BAR_NATIVE_PAGES = new Set([
|
||||
'pages/accept-order/accept-order',
|
||||
'pages/fighter-orders/fighter-orders',
|
||||
'pages/messages/messages',
|
||||
'pages/fighter/fighter',
|
||||
]);
|
||||
|
||||
Component({
|
||||
data: {
|
||||
selectedIndex: 0,
|
||||
@@ -43,6 +50,7 @@ Component({
|
||||
lifetimes: {
|
||||
attached() {
|
||||
this.refresh();
|
||||
this._restoreBadgeFromCache();
|
||||
this._badgeListener = (data) => {
|
||||
if (data.badgeText !== undefined) {
|
||||
this.setData({ badgeText: data.badgeText });
|
||||
@@ -61,20 +69,48 @@ Component({
|
||||
pageLifetimes: {
|
||||
show() {
|
||||
this.refresh();
|
||||
const globalBadge = app.globalData.messageManager?.tabBarBadgeText || '';
|
||||
if (this.data.badgeText !== globalBadge) {
|
||||
this.setData({ badgeText: globalBadge });
|
||||
}
|
||||
this._restoreBadgeFromCache();
|
||||
this._syncUnreadWithDebounce();
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
_restoreBadgeFromCache() {
|
||||
const mm = app.globalData.messageManager || {};
|
||||
let badgeText = mm.tabBarBadgeText || '';
|
||||
if (!badgeText) {
|
||||
try {
|
||||
badgeText = wx.getStorageSync('tabBarMessageBadge') || '';
|
||||
} catch (e) {}
|
||||
}
|
||||
if (!badgeText && mm.unreadTotal > 0) {
|
||||
badgeText = mm.unreadTotal > 99 ? '99+' : String(mm.unreadTotal);
|
||||
}
|
||||
if (!badgeText) {
|
||||
try {
|
||||
const saved = wx.getStorageSync('messageUnreadTotal');
|
||||
if (saved > 0) badgeText = saved > 99 ? '99+' : String(saved);
|
||||
} catch (e) {}
|
||||
}
|
||||
if (badgeText && badgeText !== this.data.badgeText) {
|
||||
this.setData({ badgeText });
|
||||
}
|
||||
if (app.restoreTabBarBadge) app.restoreTabBarBadge();
|
||||
},
|
||||
|
||||
_syncUnreadWithDebounce() {
|
||||
if (this._syncTimer) clearTimeout(this._syncTimer);
|
||||
this._syncTimer = setTimeout(() => {
|
||||
if (app && app.loadConversations) app.loadConversations();
|
||||
}, 300);
|
||||
if (app.globalData.goEasyConnection) {
|
||||
app.globalData.goEasyConnection.autoReconnect = true;
|
||||
}
|
||||
if (app.startImWhenReady) {
|
||||
app.startImWhenReady();
|
||||
} else {
|
||||
if (app.ensureConnection) app.ensureConnection();
|
||||
if (app.loadConversations) app.loadConversations();
|
||||
}
|
||||
}, 200);
|
||||
},
|
||||
|
||||
refresh() {
|
||||
@@ -104,7 +140,13 @@ Component({
|
||||
const path = e.currentTarget.dataset.path;
|
||||
const idx = e.currentTarget.dataset.index;
|
||||
if (idx === this.data.selectedIndex) return;
|
||||
wx.redirectTo({ url: '/' + path });
|
||||
const url = '/' + path;
|
||||
// tabBar 注册页用 switchTab;其余页用 reLaunch(redirectTo 对 tab 页会失败)
|
||||
if (TAB_BAR_NATIVE_PAGES.has(path)) {
|
||||
wx.switchTab({ url });
|
||||
} else {
|
||||
wx.reLaunch({ url });
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user