feat(power): 展示电池实际充放电功率并及时响应电源切换
保留电量百分比和连续趋势,按历史采样展示电池、适配器和系统功率。面板可见时读取电池实时功率,插拔电源后立即刷新并复读。
This commit is contained in:
@@ -7,6 +7,14 @@ nonisolated struct SensorReadings: Sendable {
|
||||
}
|
||||
|
||||
nonisolated enum CPUTemperatureServiceClient {
|
||||
static func readBatteryPower() async -> Double? {
|
||||
await ServiceRequest.perform(timeout: 2) { proxy, finish in
|
||||
proxy.readBatteryPower { value in
|
||||
finish(value.flatMap { abs($0.doubleValue) <= 500 ? $0.doubleValue : nil })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static func readSystemPower() async -> Double? {
|
||||
await ServiceRequest.perform(timeout: 2) { proxy, finish in
|
||||
proxy.readSystemPower { value in
|
||||
|
||||
Reference in New Issue
Block a user