feat(menubar): 拆分紧凑双页面板并按页采样

This commit is contained in:
2026-11-08 10:42:55 +08:00
parent ac8b4a7e6a
commit 41dcc497b5
36 changed files with 465 additions and 288 deletions
+13 -1
View File
@@ -35,6 +35,18 @@ nonisolated struct ProcessEnergySnapshot: Sendable {
let candidates: Int
let readable: Int
let measured: Int
let rows: [ProcessEnergyUsage] // Only the top three; no CPU prefilter.
let rows: [ProcessEnergyUsage] // All valid measurements; no CPU prefilter.
let state: State
}
nonisolated extension ProcessSnapshot {
func withEnergy(_ energy: ProcessEnergySnapshot?) -> ProcessSnapshot {
let values = Dictionary((energy?.rows ?? []).map { ($0.id, $0) }, uniquingKeysWith: { first, _ in first })
return ProcessSnapshot(date: date, enumerated: enumerated, readable: readable, rows: rows.map { process in
var row = process
row.cpuPower = values[process.id]?.watts
row.powerWindow = values[process.id]?.seconds
return row
}, failed: failed)
}
}
+6
View File
@@ -14,6 +14,12 @@ nonisolated struct ProcessMetrics: Identifiable, Sendable {
let footprintBytes: UInt64? // Physical footprint; never RSS.
let threads: Int?
let restricted: Bool
var cpuPower: Double? = nil // Average attributed CPU power, watts; not Energy Impact.
var powerWindow: TimeInterval? = nil
var formattedPower: String {
guard let cpuPower, cpuPower.isFinite, cpuPower >= 0 else { return "--" }
return cpuPower >= 1 ? String(format: "%.2f W", cpuPower) : String(format: "%.1f mW", cpuPower * 1000)
}
}
nonisolated struct ProcessSnapshot: Sendable {