From 8079242dafca19ca0860cdaa09d3bf68059f0c67 Mon Sep 17 00:00:00 2001 From: cnliucheng Date: Thu, 4 Jun 2026 16:53:53 +0800 Subject: [PATCH] fix: theme not applying to training/records pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: themeStyle was on .container only, but modals (picker, day-detail) were siblings of .container in the WXML tree. CSS custom properties set via inline style on .container don't cascade to sibling elements — those elements fall back to app.wxss page-level defaults (always orange). Users saw modal buttons in orange and concluded the whole page didn't follow theme. Fixes: - index.wxml: Move picker modal inside .container so it inherits themeStyle CSS variables (position:fixed is viewport-relative, so nesting doesn't affect modal positioning) - index.js, records.js: Add applyThemeToPage in onLoad alongside onShow, preventing a flash of default orange before onShow fires - timer.js: Add onShow with applyThemeToPage as lifecycle safety net; extract _init from onLoad for clean separation --- pages/index/index.js | 1 + pages/index/index.wxml | 62 ++++++++++++++++++++-------------------- pages/records/records.js | 1 + pages/timer/timer.js | 8 ++++++ 4 files changed, 41 insertions(+), 31 deletions(-) diff --git a/pages/index/index.js b/pages/index/index.js index debbcd8..2a01889 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -23,6 +23,7 @@ Page({ }, onLoad() { + themeMod.applyThemeToPage(this) this.refresh() }, diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 7c36254..806330a 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -76,39 +76,39 @@ 💡 保持身体成一条直线,核心收紧,均匀呼吸 - - - - - - ⏱ 选择训练时长 - - - {{item}} - + + + + + ⏱ 选择训练时长 + + + {{item}} + + + + 自定义: + + + + + 取消 - - 自定义: - - - - - 取消 diff --git a/pages/records/records.js b/pages/records/records.js index 36a2a8c..51916ac 100644 --- a/pages/records/records.js +++ b/pages/records/records.js @@ -20,6 +20,7 @@ Page({ }, onLoad() { + themeMod.applyThemeToPage(this) this.refresh() }, diff --git a/pages/timer/timer.js b/pages/timer/timer.js index a66669a..ea89fb7 100644 --- a/pages/timer/timer.js +++ b/pages/timer/timer.js @@ -21,6 +21,14 @@ Page({ onLoad(options) { themeMod.applyThemeToPage(this) + this._init(options) + }, + + onShow() { + themeMod.applyThemeToPage(this) + }, + + _init(options) { let target let planDay = 1