fix: navigation bar color not updating on per-page basis
Root cause: _setNavBarColor used _lastNavColor (a module-level cache) to skip wx.setNavigationBarColor when the color appeared unchanged. But wx.setNavigationBarColor is per-page — each tab page has its own navigation bar and needs an explicit call. The cache prevented subsequent pages from ever receiving the call. Example trace: index onShow → _setNavBarColor(#FF6B35) → _lastNavColor=#FF6B35 ✓ settings onShow → _setNavBarColor(#FF6B35) → cache hit, return ✗ User picks green → setTheme → _setNavBarColor(#43A047) ✓ index onShow → _setNavBarColor(#43A047) → cache hit, return ✗ → Index still shows orange! Fix: remove _lastNavColor guard entirely. Keep setTimeout debounce.
This commit is contained in:
@@ -44,7 +44,6 @@ const THEMES = [
|
||||
const BASE_VARS = '--text:#333;--text-secondary:#999;--bg:#F5F5F5;--card-bg:#FFFFFF;--border:#EEE;--success:#4CAF50;--primary:#FF6B35;--primary-light:#FF8C5A;--primary-bg:#FFF3ED;--primary-rgb:255,107,53;'
|
||||
const DEFAULT_THEME_ID = 'orange'
|
||||
const THEME_KEY = 'app_theme'
|
||||
let _lastNavColor = ''
|
||||
let _navColorTimer = null
|
||||
|
||||
const getThemeById = (id) => THEMES.find(t => t.id === id) || THEMES[0]
|
||||
@@ -62,8 +61,6 @@ const getCurrentTheme = () => {
|
||||
}
|
||||
|
||||
const _setNavBarColor = (primary) => {
|
||||
if (_lastNavColor === primary) return
|
||||
_lastNavColor = primary
|
||||
if (_navColorTimer) clearTimeout(_navColorTimer)
|
||||
_navColorTimer = setTimeout(() => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user