feat(menubar): 用分色进度柱展示电量、供电与睡眠历史

记录系统睡眠和唤醒区间,保留真实采样空档。电量柱按固定间距从右侧滑入,以蓝色、绿色和橙黄色分别标记外接电源、电池和睡眠,支持悬浮查看历史。
This commit is contained in:
2026-11-16 11:07:07 +08:00
parent 36518d29db
commit b9abb970d9
18 changed files with 546 additions and 45 deletions
+7
View File
@@ -50,6 +50,13 @@ import Foundation
let stopped = store.history.samples
precondition(PanelCurveGeometry.runs(dates: stopped.map(\.date), values: stopped.map(\.memory),
boundaryDates: Set(stopped.filter(\.breakBefore).map(\.date)), intervals: stopped.map(\.expectedInterval)).count == 2)
precondition(store.history.sleepIntervals.isEmpty, "Hiding and disabling recording must not mark sleep")
store.setSystemSleeping(true)
store.setSystemSleeping(true)
try await Task.sleep(for: .milliseconds(50))
store.setSystemSleeping(false)
store.setSystemSleeping(false)
precondition(store.history.sleepIntervals.count == 1 && store.history.sleepIntervals[0].duration > 0)
store.togglePause()
print("PASS: disabling background recording still stops sampling and preserves the real gap")
}