fix(macos): sync tray speed style across displays

This commit is contained in:
Tunglies
2026-07-27 14:28:29 +08:00
parent 389c5342e5
commit 5a2f1fc4c7
2 changed files with 5 additions and 3 deletions
+2
View File
@@ -2,6 +2,8 @@
### 🐞 修复问题
修复 macOS 多显示器切换时托盘速率样式不同步
<details>
<summary><strong> ✨ 新增功能 </strong></summary>
+3 -3
View File
@@ -1,7 +1,7 @@
//! macOS 托盘速率富文本渲染模块
//!
//! 通过 objc2 调用 NSAttributedString 实现托盘速率的富文本显示,
//! 支持等宽字体、自适应深色/浅色模式配色、两行定宽布局。
//! 支持等宽字体、跟随菜单栏外观配色、两行定宽布局。
use std::cell::RefCell;
@@ -56,8 +56,8 @@ fn build_attributes(button_height: f64) -> Retained<NSDictionary<NSString, AnyOb
unsafe {
// 等宽系统字体,确保数字不跳动
let font = NSFont::monospacedSystemFontOfSize_weight(TRAY_FONT_SIZE, NSFontWeightRegular);
// 自适应标签颜色(自动跟随深色/浅色模式)
let color = NSColor::labelColor();
// 与 NSStatusBarButton 原生标题一致,并按每块屏幕的菜单栏外观动态解析颜色
let color = NSColor::controlTextColor();
// 段落样式:右对齐,保证定宽视觉一致
let para_style = NSMutableParagraphStyle::new();
para_style.setAlignment(NSTextAlignment::Right);