From a5c591eaf371a660b784ee9512418344dc48c811 Mon Sep 17 00:00:00 2001 From: cnliucheng Date: Thu, 4 Jun 2026 17:08:52 +0800 Subject: [PATCH] fix: navigation bar color not updating on per-page basis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- utils/theme.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/utils/theme.js b/utils/theme.js index 8e4105c..cc2e2ec 100644 --- a/utils/theme.js +++ b/utils/theme.js @@ -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 {