fix(tabBar): 切换暗黑模式后其他 tab 的底栏不跟随变暗

根因:自定义 tabBar 的 pageLifetimes.show() 不触发(微信框架
特殊行为),各 tab 页 onShow 只设了 selected 没同步主题;
onSelectDarkMode 里 getCurrentPages() 只返回当前 tab 页,
其他 tab 的 tabBar 实例未收到更新。

修复:4 个 tab 页 onShow 里 tb.setData({selected:X}) 后加
tb.updateTheme(),显式同步主题。updateTheme 内部有样式未变
则跳过的优化,不会多余渲染。
This commit is contained in:
2026-08-14 08:45:19 +08:00
parent b6d94b21cd
commit aa905b1d09
7 changed files with 25 additions and 5 deletions
+4 -1
View File
@@ -114,7 +114,10 @@ Page({
onShow() {
try {
const tb = this.getTabBar()
if (tb) tb.setData({ selected: 3 })
if (tb) {
tb.setData({ selected: 3 })
tb.updateTheme()
}
} catch (e) {}
themeMod.applyThemeToPage(this)
const theme = themeMod.getCurrentTheme()