@@ -168,30 +168,41 @@ public string GetFormattedText(bool isHorizontal)
168168
169169 // [Refactor] 使用新的原子函数分别构建普通和紧凑文本
170170
171- // 1. 标准模式 (Panel)
171+ // === 1. 更新主界面缓存 (Panel) ===
172172 string valNormal = MetricUtils . GetValueStr ( Key , DisplayValue , false ) ;
173173 string unitNormal = MetricUtils . GetUnitStr ( Key , DisplayValue , MetricUtils . UnitContext . Panel ) ;
174+ string userFmtPanel = cfg ? . UnitPanel ;
174175
175- CachedValueText = valNormal ;
176- CachedUnitText = MetricUtils . GetDisplayUnit ( Key , unitNormal , userFormat ) ;
177- _cachedNormalText = CachedValueText + CachedUnitText ;
176+ string finalUnitPanel = MetricUtils . GetDisplayUnit ( Key , unitNormal , userFmtPanel ) ;
177+ _cachedNormalText = valNormal + finalUnitPanel ;
178178
179- // 2. 紧凑模式 (Taskbar/Horizontal)
180- if ( HasCustomUnit )
179+ // === 2. 更新任务栏缓存 (Taskbar/Horizontal) ===
180+ // 逻辑修正:任务栏模式下,必须使用 Taskbar 上下文 (例如不带 /s)
181+ string userFmtTaskbar = cfg ? . UnitTaskbar ;
182+ bool hasCustomTaskbar = ! string . IsNullOrEmpty ( userFmtTaskbar ) ;
183+
184+ // 自动模式:启用数值压缩 (Compact=true) 和 紧凑单位 (Taskbar Context)
185+ // 自定义模式:不做数值压缩 (false),但单位仍需基于 Taskbar 上下文计算基础值
186+ bool compact = ! hasCustomTaskbar ;
187+
188+ string valTaskbar = MetricUtils . GetValueStr ( Key , DisplayValue , compact ) ;
189+ string unitTaskbar = MetricUtils . GetUnitStr ( Key , DisplayValue , MetricUtils . UnitContext . Taskbar ) ;
190+
191+ string finalUnitTaskbar = MetricUtils . GetDisplayUnit ( Key , unitTaskbar , userFmtTaskbar ) ;
192+ _cachedHorizontalText = valTaskbar + finalUnitTaskbar ;
193+
194+ // 更新公共属性以便调试 (显示当前请求模式的值)
195+ if ( isHorizontal )
181196 {
182- // 自定义单位模式下,不做数值压缩,保持与 Panel 一致
183- _cachedHorizontalText = _cachedNormalText ;
197+ CachedValueText = valTaskbar ;
198+ CachedUnitText = finalUnitTaskbar ;
199+ HasCustomUnit = hasCustomTaskbar ;
184200 }
185201 else
186202 {
187- // 自动模式:启用数值压缩 (Compact=true) 和 紧凑单位 (Taskbar Context)
188- string valCompact = MetricUtils . GetValueStr ( Key , DisplayValue , true ) ;
189- string unitCompact = MetricUtils . GetUnitStr ( Key , DisplayValue , MetricUtils . UnitContext . Taskbar ) ;
190-
191- // 确保单位正确注入 (虽然 Auto 模式下 GetDisplayUnit 通常直接返回 unitCompact)
192- string finalUnitCompact = MetricUtils . GetDisplayUnit ( Key , unitCompact , null ) ;
193-
194- _cachedHorizontalText = valCompact + finalUnitCompact ;
203+ CachedValueText = valNormal ;
204+ CachedUnitText = finalUnitPanel ;
205+ HasCustomUnit = ! string . IsNullOrEmpty ( userFmtPanel ) ;
195206 }
196207
197208 // Only calculate color if NOT a plugin item (already handled above)
0 commit comments