feat(monitors): 实现 CPU 内存采样诊断与菜单栏实时指标

接入 Mach CPU 差分、内存与负载采样、暂停恢复及按需诊断,合并菜单栏单一原生标题的显示修复。
保留核心检查和本机交互验收记录;长期资源预算仍待验收。
This commit is contained in:
2026-10-30 00:45:34 +08:00
parent 42791b2ee7
commit 631b412d15
19 changed files with 483 additions and 36 deletions
+30
View File
@@ -0,0 +1,30 @@
import SwiftUI
struct MenuBarLabel: View {
let snapshot: MetricsSnapshot
var body: some View {
// Use one native image/title label: the previous multi-view HStack showed
// only its first image and percentage in the user-verified menu bar.
Label {
Text(verbatim: title)
.monospacedDigit()
} icon: {
Image(systemName: "gauge")
}
.labelStyle(.titleAndIcon)
}
private var title: String {
var items = ["CPU \(percent(snapshot.cpu?.usage))"]
if let gpu = snapshot.gpuUsage {
items.append("GPU \(percent(gpu))")
}
items.append("MEM \(percent(snapshot.memory?.usage))")
return items.joined(separator: " · ")
}
private func percent(_ value: Double?) -> String {
value.map { "\(Int(($0 * 100).rounded()))%" } ?? "--"
}
}