feat(power): 展示电池实际充放电功率并及时响应电源切换

保留电量百分比和连续趋势,按历史采样展示电池、适配器和系统功率。面板可见时读取电池实时功率,插拔电源后立即刷新并复读。
This commit is contained in:
2026-11-15 23:54:19 +08:00
parent 1595af6d13
commit 4b8deb2e48
31 changed files with 739 additions and 119 deletions
+10
View File
@@ -19,6 +19,16 @@ import QuartzCore
func input(_ values: [Double?]) -> NativePanelCurve.Input {
NativePanelCurve.Input(frame: PanelCurveFrame(dates: dates, series: [values], intervals: [2,2,2,2], boundaryDates: []), colors: [.red], scales: [1], maximumGap: 5)
}
var signed = input([-1, 0, 0.5, 1])
signed.projection = .signed
signed.hoveredIndex = 0
plot.configure(signed)
let dischargeDot = plot.layer!.sublayers!.last as! CAShapeLayer
precondition(dischargeDot.path!.boundingBoxOfPath.midY == 60)
precondition(plot.baseline.path!.boundingBoxOfPath.midY == 30)
signed.hoveredIndex = 3
plot.configure(signed)
precondition(dischargeDot.path!.boundingBoxOfPath.midY == 0)
let continuous = input([0.8,0.8,0.8,0.8])
plot.configure(continuous)
let image = bitmap(plot)