fix(dark): 调亮暗黑色调 + dock 跟随暗黑切换 + 图标文字放大
- theme/app.wxss: 暗黑背景 #0F0F12->#2C2C2E,卡片 #1C1C1E->#3A3A3C, bg-soft/border 同步提亮,拉开卡片与背景对比(原太黑看不到卡片) - custom-tab-bar: dock 注册 wx.onThemeChange,系统切暗黑/明亮实时跟随 (组件不在 getCurrentPages,app.js watchDarkMode 通知不到) - custom-tab-bar: 新增 updateTheme,settings 手动切深色时通知 dock - custom-tab-bar.wxss: dock 图标 44->50rpx,文字 20->23rpx,未激活 opacity 0.5->0.7(更醒目) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -62,6 +62,20 @@ Component({
|
||||
// Rebuild icons in case the user changed theme/dark mode since module load
|
||||
const theme = themeMod.getCurrentTheme()
|
||||
this.setData({ svgIcons: _buildIcons(theme.primary, _getInactiveColor()) })
|
||||
// The custom tabBar isn't in getCurrentPages(), so app.js's
|
||||
// watchDarkMode (which notifies pages) never reaches it. Listen for
|
||||
// system theme changes ourselves so the dock flips dark/light live,
|
||||
// not just on the next tab switch.
|
||||
if (!this._themeChangeBound && typeof wx.onThemeChange === 'function') {
|
||||
this._onThemeChange = () => {
|
||||
themeMod.applyThemeToPage(this)
|
||||
this.setData({ svgIcons: _buildIcons(themeMod.getCurrentTheme().primary, _getInactiveColor()) })
|
||||
}
|
||||
try {
|
||||
wx.onThemeChange(this._onThemeChange)
|
||||
this._themeChangeBound = true
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -84,6 +98,12 @@ Component({
|
||||
]
|
||||
if (index === this.data.selected) return
|
||||
wx.switchTab({ url: pages[index] })
|
||||
},
|
||||
// Called by settings.onSelectDarkMode - the dock isn't in
|
||||
// getCurrentPages() so the page-loop there misses it.
|
||||
updateTheme() {
|
||||
themeMod.applyThemeToPage(this)
|
||||
this.setData({ svgIcons: _buildIcons(themeMod.getCurrentTheme().primary, _getInactiveColor()) })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user