feat(panel): 调整资源卡片读数布局并保留趋势平移

逐核显示 CPU 占用,在 GPU 标题展示核数并补充分项读数。无电池设备显示整机功率。

存储与网络将曲线排在详情下方,CPU、GPU、内存和电池保留整卡趋势。数值直接刷新,曲线随采样平滑平移。顶栏展示版本号,底栏调整开机时间和刷新间隔。
This commit is contained in:
2026-11-15 22:03:46 +08:00
parent c886c4227d
commit 6300db3d15
27 changed files with 427 additions and 250 deletions
+10 -5
View File
@@ -1,6 +1,6 @@
import SwiftUI
/// Core-kind columns contain one vertical segmented meter per real core.
/// Core-kind columns contain one continuously filled cell per real core.
struct CPUCoreGrid: View {
let values: [Double]
let kinds: [Int: CPUCoreTopology.Kind]
@@ -85,8 +85,13 @@ struct CPUCoreGrid: View {
private func core(index: Int) -> some View {
let kind = kinds[index]
let measured = values[index].isFinite ? values[index] : nil
return SegmentedCoreBar(value: measured, color: color(kind))
.frame(height: 30)
return RoundedRectangle(cornerRadius: 2)
.fill(color(kind).opacity(0.22))
.overlay(alignment: .bottom) {
Rectangle().fill(color(kind)).frame(height: CPUCoreGridLayout.rowHeight * (measured.map { min(1, max(0, $0)) } ?? 0))
}
.clipShape(.rect(cornerRadius: 2))
.frame(height: CPUCoreGridLayout.rowHeight)
.frame(maxWidth: .infinity, maxHeight: .infinity)
.help(Text("\(kind.map { label($0) } ?? Text("cpu.core")) · \(index + 1): \(MetricFormat.percent(measured))"))
.accessibilityElement(children: .ignore)
@@ -98,8 +103,8 @@ struct CPUCoreGrid: View {
struct CPUCoreGridLayout: Layout {
static let columnSpacing: CGFloat = 3
static let rowSpacing: CGFloat = 4
static let rowHeight: CGFloat = 30
static let minimumCellWidth: CGFloat = 6
static let rowHeight: CGFloat = 11
static let minimumCellWidth: CGFloat = 7
static func rowCounts(count: Int, width: CGFloat) -> [Int] {
guard count > 0 else { return [] }