feat(panel): 调整资源卡片读数布局并保留趋势平移
逐核显示 CPU 占用,在 GPU 标题展示核数并补充分项读数。无电池设备显示整机功率。 存储与网络将曲线排在详情下方,CPU、GPU、内存和电池保留整卡趋势。数值直接刷新,曲线随采样平滑平移。顶栏展示版本号,底栏调整开机时间和刷新间隔。
This commit is contained in:
@@ -1,12 +1,29 @@
|
||||
import Foundation
|
||||
|
||||
/// A static render frame follows the bounded sampling history without outgoing points.
|
||||
/// History remains bounded; a rolling plot can draw one outgoing vertex beyond its left edge.
|
||||
nonisolated struct PanelCurveFrame: Equatable {
|
||||
let dates: [Date]
|
||||
let series: [[Double?]]
|
||||
let intervals: [TimeInterval]
|
||||
let boundaryDates: Set<Date>
|
||||
|
||||
/// Only adjacent samples from the same timeline can slide into view.
|
||||
func follows(_ old: Self, maximumGap: TimeInterval) -> Bool {
|
||||
guard old.dates.count >= 2, let before = old.dates.last, let end = dates.last,
|
||||
let begin = old.dates.first, begin < before, end > before, !boundaryDates.contains(end),
|
||||
end.timeIntervalSince(before) <= PanelCurveGeometry.allowedGap(at: dates.count - 1, intervals: intervals, fallback: maximumGap)
|
||||
else { return false }
|
||||
return dates.dropLast().elementsEqual(old.dates)
|
||||
|| (dates.count == old.dates.count && dates.dropLast().elementsEqual(old.dates.dropFirst()))
|
||||
}
|
||||
|
||||
func includingOutgoing(from old: Self) -> Self {
|
||||
guard dates.first != old.dates.first, let outgoing = old.dates.first else { return self }
|
||||
return Self(dates: [outgoing] + dates, series: series.enumerated().map { index, values in
|
||||
[old.series.indices.contains(index) ? old.series[index].first ?? nil : nil] + values
|
||||
}, intervals: [old.intervals.first ?? 2] + intervals, boundaryDates: boundaryDates)
|
||||
}
|
||||
|
||||
struct Domain {
|
||||
let begin: TimeInterval
|
||||
let end: TimeInterval
|
||||
|
||||
Reference in New Issue
Block a user