接入有界趋势、平滑滚动、菜单式外侧详情、底部操作与三语文案,装配独立外观设置和 Dock 生命周期。 合并跟随系统外观刷新、自选颜色入口与色块绘制修复,保留用户确认的配色联动、重启保存及滚动验收。 多场景视觉与长期资源验证边界仍记录于 docs。
21 lines
676 B
Swift
21 lines
676 B
Swift
import Foundation
|
|
|
|
nonisolated struct TrendSample: Sendable {
|
|
let date: Date
|
|
let cpu: Double?
|
|
let gpu: Double?
|
|
let memory: Double?
|
|
}
|
|
|
|
/// Bounded sampling history; no timer or UI visibility dependence.
|
|
nonisolated struct MetricHistory: Sendable {
|
|
static let capacity = 60
|
|
private(set) var samples: [TrendSample] = []
|
|
|
|
mutating func append(_ snapshot: MetricsSnapshot) {
|
|
samples.append(TrendSample(date: snapshot.date, cpu: snapshot.cpu?.usage,
|
|
gpu: snapshot.gpuUsage, memory: snapshot.memory?.usage))
|
|
if samples.count > Self.capacity { samples.removeFirst(samples.count - Self.capacity) }
|
|
}
|
|
}
|