feat(power): 展示电池实际充放电功率并及时响应电源切换
保留电量百分比和连续趋势,按历史采样展示电池、适配器和系统功率。面板可见时读取电池实时功率,插拔电源后立即刷新并复读。
This commit is contained in:
@@ -26,6 +26,12 @@ nonisolated enum MetricFormat {
|
||||
return String(format: "%.1f %@", scaled, units[index])
|
||||
}
|
||||
|
||||
static func signedWatts(_ value: Double?) -> String {
|
||||
guard let value, value.isFinite else { return "--" }
|
||||
if abs(value) < 0.05 { return "0 W" }
|
||||
return (value < 0 ? "−" : "+") + watts(abs(value))
|
||||
}
|
||||
|
||||
static func watts(_ value: Double?) -> String {
|
||||
guard let value, value.isFinite, value >= 0 else { return "--" }
|
||||
return String(format: "%.1f W", value)
|
||||
|
||||
Reference in New Issue
Block a user