From efeeadd8348303a510721dd21d27f3c9af8996dd Mon Sep 17 00:00:00 2001 From: Yao Jingxi <23722032@bjtu.edu.cn> Date: Sun, 1 Nov 2026 11:45:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(macos):=20=E7=8A=B6=E6=80=81=E6=A0=8F?= =?UTF-8?q?=E5=86=85=E5=AD=98=E5=8F=AA=E6=98=BE=E7=A4=BA=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=EF=BC=8C=E5=B8=A7=E7=8E=87=E5=8E=BB=E6=8E=89=E5=9B=BE=E6=A0=87?= =?UTF-8?q?=E5=B9=B6=E6=94=B6=E7=B4=A7=E9=97=B4=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 内存指示器只保留内存芯片图标,不再常驻显示“总计 / Lithe”数值; 悬停提示仍给出总计、Lithe、LSP、服务内存,点击打开原有的托管内存详情, VoiceOver 读出“托管内存”和当前总计。 - 帧率只显示“60 FPS”文字,去掉速度表图标。 - 新增 18pt 的状态栏紧凑图标按钮样式,只读锁和内存图标改用它, 不再沿用 28pt 工具窗口按钮留出的大块空白。 - 删除不再使用的 "Total %@" 词条并重新生成本地化资源。 - 更新 memory-monitor 功能矩阵的 macOS 证据与验收说明。 --- macos/Resources/en.lproj/Localizable.strings | 2 -- .../zh-Hans.lproj/Localizable.strings | 2 -- macos/Sources/Lithe/Theme/LitheTheme.swift | 14 ++++++++ .../Workbench/WorkbenchStatusViews.swift | 32 +++++++------------ .../Lithe/Views/Workbench/WorkbenchView.swift | 2 +- shared/i18n/locales/en-US.json | 1 - shared/i18n/locales/zh-CN.json | 1 - shared/i18n/messages.json | 16 ---------- .../features/memory-monitor.json | 5 +-- 9 files changed, 30 insertions(+), 45 deletions(-) diff --git a/macos/Resources/en.lproj/Localizable.strings b/macos/Resources/en.lproj/Localizable.strings index d4a91515b2..d77bb0887a 100644 --- a/macos/Resources/en.lproj/Localizable.strings +++ b/macos/Resources/en.lproj/Localizable.strings @@ -4325,7 +4325,6 @@ "Tools" = "Tools"; "Tools sent" = "Tools sent"; "Total" = "Total"; -"Total %@" = "Total %@"; "Total tokens: %@" = "Total tokens: %@"; "Tracking %@" = "Tracking %@"; "Tracking Branch" = "Tracking Branch"; @@ -9053,7 +9052,6 @@ "native.tools" = "Tools"; "native.toolsSent" = "Tools sent"; "native.total" = "Total"; -"native.total.variant2" = "Total %1$@"; "native.totalTokens" = "Total tokens: %1$@"; "native.tracking" = "Tracking %1$@"; "native.trackingBranch" = "Tracking Branch"; diff --git a/macos/Resources/zh-Hans.lproj/Localizable.strings b/macos/Resources/zh-Hans.lproj/Localizable.strings index ca32b7f055..f716ce8e46 100644 --- a/macos/Resources/zh-Hans.lproj/Localizable.strings +++ b/macos/Resources/zh-Hans.lproj/Localizable.strings @@ -4325,7 +4325,6 @@ "Tools" = "工具"; "Tools sent" = "发送的工具"; "Total" = "总计"; -"Total %@" = "总计 %@"; "Total tokens: %@" = "总 token:%@"; "Tracking %@" = "跟踪 %@"; "Tracking Branch" = "跟踪的分支"; @@ -9053,7 +9052,6 @@ "native.tools" = "工具"; "native.toolsSent" = "发送的工具"; "native.total" = "总计"; -"native.total.variant2" = "总计 %1$@"; "native.totalTokens" = "总 token:%1$@"; "native.tracking" = "跟踪 %1$@"; "native.trackingBranch" = "跟踪的分支"; diff --git a/macos/Sources/Lithe/Theme/LitheTheme.swift b/macos/Sources/Lithe/Theme/LitheTheme.swift index b11a7c962a..1203f3dde0 100644 --- a/macos/Sources/Lithe/Theme/LitheTheme.swift +++ b/macos/Sources/Lithe/Theme/LitheTheme.swift @@ -986,6 +986,9 @@ enum LitheTheme { static let toolbarHeight: CGFloat = 40 static let toolWindowHeaderHeight: CGFloat = 41 static let statusBarHeight: CGFloat = 24 + // Status bar icon widgets stay inside the 24pt bar so neighbouring + // items do not inherit the 28pt tool-window hit box as empty gaps. + static let statusBarIconButtonSize: CGFloat = 18 static let cornerRadius: CGFloat = 5 static let popupShadowRadius: CGFloat = 30 static let popupShadowOffsetY: CGFloat = 14 @@ -1050,6 +1053,17 @@ extension View { .lithePointer() } + /// Compact icon button for status bar widgets; inherits the bar's + /// secondary text color instead of the tool-window foreground. + func litheStatusBarIconButton() -> some View { + self + .buttonStyle(LitheIconButtonStyle( + size: LitheTheme.Metrics.statusBarIconButtonSize, + foreground: LitheTheme.secondaryText, + cornerRadius: 4)) + .lithePointer() + } + /// Shows the macOS pointing-hand cursor while an interactive control is /// hovered. The push/pop pair is balanced even when a view disappears. func lithePointer() -> some View { diff --git a/macos/Sources/Lithe/Views/Workbench/WorkbenchStatusViews.swift b/macos/Sources/Lithe/Views/Workbench/WorkbenchStatusViews.swift index 2fa19b88c5..c383256c37 100644 --- a/macos/Sources/Lithe/Views/Workbench/WorkbenchStatusViews.swift +++ b/macos/Sources/Lithe/Views/Workbench/WorkbenchStatusViews.swift @@ -21,6 +21,9 @@ struct EditorCaretPositionLabel: View { } } +/// Icon-only memory indicator: the status bar keeps just the chip so the +/// figures do not crowd the bar; hover shows the totals and a click opens the +/// detailed breakdown. struct MemoryUsageStatusView: View { @EnvironmentObject private var memoryUsageMonitor: MemoryUsageMonitor @State private var isMemoryUsagePopoverPresented = false @@ -29,19 +32,11 @@ struct MemoryUsageStatusView: View { Button { isMemoryUsagePopoverPresented.toggle() } label: { - Label { - HStack(spacing: 4) { - Text("Total \(memoryUsageMonitor.totalText)") - Text("·") - Text("Lithe \(memoryUsageMonitor.litheText)") - } - .monospacedDigit() - } icon: { - Image(systemName: "memorychip") - } + Image(systemName: "memorychip") } - .buttonStyle(.litheNoPress) - .lithePointer() + .litheStatusBarIconButton() + .accessibilityLabel(Text("Managed Memory")) + .accessibilityValue(Text(memoryUsageMonitor.totalText)) .help( Text( "Total managed memory: \(memoryUsageMonitor.totalText)\n" + @@ -134,17 +129,14 @@ struct MemoryUsageStatusView: View { } } +/// Text-only frame rate readout; the "FPS" unit already names the metric. struct FrameRateStatusView: View { @EnvironmentObject private var frameRateMonitor: FrameRateMonitor var body: some View { - Label { - Text(frameRateMonitor.framesPerSecondText) - .monospacedDigit() - } icon: { - Image(systemName: "speedometer") - } - .help("Frames rendered per second") - .accessibilityLabel(Text("\(frameRateMonitor.framesPerSecond) frames per second")) + Text(frameRateMonitor.framesPerSecondText) + .monospacedDigit() + .help("Frames rendered per second") + .accessibilityLabel(Text("\(frameRateMonitor.framesPerSecond) frames per second")) } } diff --git a/macos/Sources/Lithe/Views/Workbench/WorkbenchView.swift b/macos/Sources/Lithe/Views/Workbench/WorkbenchView.swift index 50e44dca5b..8c1777af1a 100644 --- a/macos/Sources/Lithe/Views/Workbench/WorkbenchView.swift +++ b/macos/Sources/Lithe/Views/Workbench/WorkbenchView.swift @@ -1825,7 +1825,7 @@ struct WorkbenchView: View { } label: { Image(systemName: model.activeDocument?.isReadOnly == true ? "lock.fill" : "lock.open") } - .litheIconButton() + .litheStatusBarIconButton() .disabled(model.activeDocument?.isReadOnly == true) .help(LocalizedStringKey( model.activeDocument?.isReadOnly == true ? "Read-only document" : "Save" diff --git a/shared/i18n/locales/en-US.json b/shared/i18n/locales/en-US.json index b26ba6b8af..a79c4e7d9b 100644 --- a/shared/i18n/locales/en-US.json +++ b/shared/i18n/locales/en-US.json @@ -9339,7 +9339,6 @@ "native.terminalActions": "Terminal actions", "native.close": "Close {arg1}", "native.startingModule": "Starting module...", - "native.total.variant2": "Total {arg1}", "native.framesRenderedPerSecond": "Frames rendered per second", "native.lldFramesPerSecond": "{arg1} frames per second", "native.discardAndRetry": "Discard and Retry", diff --git a/shared/i18n/locales/zh-CN.json b/shared/i18n/locales/zh-CN.json index 8ea52e14b0..559628f6a6 100644 --- a/shared/i18n/locales/zh-CN.json +++ b/shared/i18n/locales/zh-CN.json @@ -9339,7 +9339,6 @@ "native.terminalActions": "终端操作", "native.close": "关闭 {arg1}", "native.startingModule": "正在启动模块…", - "native.total.variant2": "总计 {arg1}", "native.framesRenderedPerSecond": "每秒渲染帧数", "native.lldFramesPerSecond": "每秒 {arg1} 帧", "native.discardAndRetry": "放弃并重试", diff --git a/shared/i18n/messages.json b/shared/i18n/messages.json index 3068c8aa8a..4a859896ed 100644 --- a/shared/i18n/messages.json +++ b/shared/i18n/messages.json @@ -88094,22 +88094,6 @@ "arguments": [] } }, - { - "id": "native.total.variant2", - "description": "Native UI: Total %@", - "platforms": [ - "macos" - ], - "macos": { - "key": "Total %@", - "arguments": [ - "arg1" - ] - }, - "parameters": { - "arg1": "string" - } - }, { "id": "native.framesRenderedPerSecond", "description": "Native UI: Frames rendered per second", diff --git a/shared/platform-feature-matrix/features/memory-monitor.json b/shared/platform-feature-matrix/features/memory-monitor.json index d0de491281..aecdf3c588 100644 --- a/shared/platform-feature-matrix/features/memory-monitor.json +++ b/shared/platform-feature-matrix/features/memory-monitor.json @@ -5,7 +5,8 @@ "capability": "应用与语言服务内存监控", "macos": { "evidence": [ - "macos/Sources/Lithe/Services/Monitoring/MemoryUsageMonitor.swift" + "macos/Sources/Lithe/Services/Monitoring/MemoryUsageMonitor.swift", + "macos/Sources/Lithe/Views/Workbench/WorkbenchStatusViews.swift" ], "implementationStatus": "implemented", "verificationStatus": "pending" @@ -19,5 +20,5 @@ "verificationStatus": "pending" }, "owner": "Workbench", - "verification": "打开内存指标并观察应用、语言服务和总内存变化,确认采样失败不会阻塞工作台。" + "verification": "打开内存指标并观察应用、语言服务和总内存变化,确认采样失败不会阻塞工作台。macOS 状态栏只显示内存芯片图标,不再显示总计与 Lithe 数值;悬停提示显示总计、Lithe、LSP 和服务内存,点击图标打开托管内存详情并在关闭后停止详细采样,VoiceOver 读出托管内存及当前总计。同一状态栏中帧率只显示数字和 FPS 单位,不带图标;只读锁和内存图标按钮使用 18pt 紧凑尺寸,相邻项之间不再留出大块空白。Windows 状态栏仍显示总计与 Lithe 数值。" }