feat(monitors): 为无内置电池的 Mac 采样整机即时功率

加入整机功率采样、XPC 读取和历史记录,并覆盖无电池设备的采样分支。
This commit is contained in:
2026-11-15 22:03:46 +08:00
parent e2f88023d6
commit c886c4227d
10 changed files with 58 additions and 2 deletions
@@ -7,6 +7,14 @@ nonisolated struct SensorReadings: Sendable {
}
nonisolated enum CPUTemperatureServiceClient {
static func readSystemPower() async -> Double? {
await ServiceRequest.perform(timeout: 2) { proxy, finish in
proxy.readSystemPower { value in
finish(value.flatMap { $0.doubleValue.isFinite && $0.doubleValue > 0 ? $0.doubleValue : nil })
}
}
}
static func readSensors(cpu: Bool, gpu: Bool, fans: Bool) async -> SensorReadings? {
await ServiceRequest.perform(timeout: 2) { proxy, finish in
proxy.readSensors(cpu: cpu, gpu: gpu, fans: fans) { cpu, gpu, fans in