feat(storage): 按容量分布与设备状态重设计存储卡片

This commit is contained in:
2026-11-03 17:09:39 +08:00
parent 74f6bdd7f7
commit 6d79ea1856
5 changed files with 238 additions and 8 deletions
+2
View File
@@ -210,3 +210,5 @@ CPU、GPU、电池在三列及窄屏网格中共享显式行高:基础 260pt
内存容量、曲线轴及悬浮值统一按二进制 GiB 展示,其他存储字节格式不变。MemoryMonitor 从 VM external_page_count 与 purgeable_count 提供可回收文件缓存估算;缓存不是额外物理容量,不叠加到分布条。MemoryDetailsView 展示应用、联动、压缩、可用分布,统一 Capsule 裁切避免小数值溢出;系统压力等级与用量百分比分开,不生成压力百分比或曲线。
内存分类历史由 MetricHistory 随每次采样保存应用、联动、压缩的字节值,缺失保持 nil,不使用当前分类回填过去。PanelTrendChart 支持可选四序列;内存采用总量与三类分量同一容量轴,配色与分类条一致,总量单独使用青色。
存储卡片由 MenuPanelView 装配趋势与 StorageDetailsView:前者仍显示全部块设备读写,后者展示主目录所在卷已用/可用容量、利用率、物理设备预计剩余寿命与通电时间,并通过回调打开原有卷详情。容量条整体 Capsule 裁切且不设最小填充宽度;未知值显示 --,不生成健康状态判断。两类统计范围分别通过图表下方标签和容量标题帮助说明。底部三列双行左对齐、竖线分隔,保留容量与设备状态 30 秒更新说明,不改变采样链路。
+5
View File
@@ -227,3 +227,8 @@ GPU 专项第二轮:已完成 LLDB 失败分支定位、探针调用原样转
### 内存分类历史曲线
- 新增应用、联动、压缩历史曲线,保留总量,所有值采用 GiB 轴及悬浮格式;总量青色、应用蓝色、联动紫色、压缩琥珀色。
- MemoryChecks 覆盖分类历史存储与采样失败后保持缺失值;完整面板的四图例密度与交互效果尚待重新运行验收。
## 存储卡片布局(2026-11-03)
- 按概念图新增容量分布、已用/可用双行信息;底部剩余寿命、通电时间、本地卷入口三列左对齐,删除重复读写数据。
- 容量条整体圆角裁切,不设最小填充宽度;遵循减少动态效果。保持主目录卷容量与全部块设备 I/O 的原有统计口径。
- Debug 签名构建、git diff --check、本地化 JSON 校验通过。保留用户已有 Xcode 启动实例(PID 45331),未重启;实际 240pt 卡片布局、卷详情弹窗与低值动画尚待新版本运行验收。
+8 -8
View File
@@ -315,14 +315,14 @@ struct MenuPanelView: View {
ResourceCard(title: "metric.disk", symbol: "internaldrive", color: Color("MetricDisk"), value: snapshot.disk.map { String(format: "%.0f / %.0f GB", Double($0.total - min($0.total, $0.available)) / 1_000_000_000, Double($0.total) / 1_000_000_000) } ?? "--") {
PanelTrendChart(dates: samples.map(\.date), first: samples.map(\.read), second: samples.map(\.write), color: Color("MetricDisk"), secondColor: Color("MetricNetwork"), fixedScale: nil, firstLabel: "disk.read", secondLabel: "disk.write", expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals)
Text("disk.physicalIO").foregroundStyle(.secondary)
HStack { line("disk.read", MetricFormat.rate(snapshot.diskIO?.read)); line("disk.write", MetricFormat.rate(snapshot.diskIO?.written)) }
HStack { line("disk.remainingLife", MetricFormat.percent(snapshot.diskHealth?.remainingLife)); line("disk.powerOnHours", snapshot.diskHealth?.powerOnHours.map { "\($0) h" } ?? "--") }
Spacer(minLength: 0)
Button("disk.volumes") { showVolumes.toggle() }.popover(isPresented: $showVolumes) {
PanelTrendChart(dates: samples.map(\.date), first: samples.map(\.read), second: samples.map(\.write), color: Color("MetricDisk"), secondColor: Color("MetricNetwork"), fixedScale: nil, firstLabel: "disk.read", secondLabel: "disk.write", expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals, plotHeight: 48)
Text("disk.physicalIO")
.font(.system(size: 9)).foregroundStyle(.secondary)
.frame(maxWidth: .infinity, alignment: .trailing)
StorageDetailsView(disk: snapshot.disk, health: snapshot.diskHealth) {
showVolumes.toggle()
}
.popover(isPresented: $showVolumes) {
VStack(alignment: .leading, spacing: 8) {
Text("disk.homeVolume")
Text("panel.smartScope").foregroundStyle(.secondary)
@@ -0,0 +1,69 @@
import SwiftUI
struct StorageDetailsView: View {
let disk: DiskMetrics?
let health: DiskHealthMetrics?
let showVolumes: () -> Void
@Environment(\.accessibilityReduceMotion) private var reduceMotion
private let color = Color("MetricDisk")
var body: some View {
VStack(alignment: .leading, spacing: 4) {
Divider()
HStack {
Text("disk.distribution").fontWeight(.semibold).help(Text("disk.capacityScope"))
Spacer()
Text("disk.utilization").foregroundStyle(.secondary)
AnimatedMetricText(value: MetricFormat.percent(disk?.usage)).foregroundStyle(color)
}
GeometryReader { proxy in
ZStack(alignment: .leading) {
Rectangle().fill(Color("MemoryAvailable"))
Rectangle().fill(color)
.frame(width: proxy.size.width * CGFloat(disk?.usage ?? 0))
}
// Clip the whole track, with no minimum fill width for tiny values.
.clipShape(Capsule())
.animation(reduceMotion ? nil : .easeInOut(duration: 0.35), value: disk?.usage)
}.frame(height: 7).accessibilityHidden(true)
HStack {
capacity("disk.used", value: disk.map { $0.total - min($0.total, $0.available) }, tint: color)
capacity("memory.available", value: disk?.available, tint: Color("MemoryAvailable"))
}
Divider()
HStack(alignment: .top, spacing: 8) {
VStack(alignment: .leading, spacing: 4) {
Text("disk.remainingLife").foregroundStyle(.secondary)
AnimatedMetricText(value: MetricFormat.percent(health?.remainingLife))
}.frame(maxWidth: .infinity, alignment: .leading)
Divider().frame(height: 30)
VStack(alignment: .leading, spacing: 4) {
Text("disk.powerOnHours").foregroundStyle(.secondary)
AnimatedMetricText(value: health?.powerOnHours.map { "\($0) h" } ?? "--")
}.frame(maxWidth: .infinity, alignment: .leading)
Divider().frame(height: 30)
VStack(alignment: .leading, spacing: 4) {
Text("disk.localVolumes").foregroundStyle(.secondary)
Button(action: showVolumes) {
HStack(spacing: 2) {
Text("disk.viewDetails")
Image(systemName: "chevron.right").font(.system(size: 8))
}
}.buttonStyle(.plain)
}.frame(maxWidth: .infinity, alignment: .leading)
}.font(.system(size: 10)).lineLimit(1).minimumScaleFactor(0.7)
Text("disk.refreshNote").font(.system(size: 9)).foregroundStyle(.secondary)
}.padding(.top, 3)
}
private func capacity(_ title: LocalizedStringKey, value: UInt64?, tint: Color) -> some View {
VStack(alignment: .leading, spacing: 3) {
HStack(spacing: 4) {
Circle().fill(tint).frame(width: 4, height: 4)
Text(title).foregroundStyle(.secondary)
}
AnimatedMetricText(value: MetricFormat.bytes(value)).fontWeight(.medium)
}.frame(maxWidth: .infinity, alignment: .leading)
.font(.system(size: 10)).lineLimit(1)
}
}
+154
View File
@@ -1495,6 +1495,160 @@
}
}
},
"disk.distribution" : {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Capacity distribution"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "容量分布"
}
},
"zh-Hant": {
"stringUnit": {
"state": "translated",
"value": "容量分佈"
}
}
}
},
"disk.utilization" : {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Utilization"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "利用率"
}
},
"zh-Hant": {
"stringUnit": {
"state": "translated",
"value": "使用率"
}
}
}
},
"disk.used" : {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Used"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "已用"
}
},
"zh-Hant": {
"stringUnit": {
"state": "translated",
"value": "已用"
}
}
}
},
"disk.capacityScope" : {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Capacity of the home volume; APFS volumes may share space"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "主目录所在卷的容量;APFS 卷可能共享空间"
}
},
"zh-Hant": {
"stringUnit": {
"state": "translated",
"value": "主目錄所在卷宗的容量;APFS 卷宗可能共享空間"
}
}
}
},
"disk.localVolumes" : {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Local volumes"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "本地卷"
}
},
"zh-Hant": {
"stringUnit": {
"state": "translated",
"value": "本機卷宗"
}
}
}
},
"disk.viewDetails" : {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "View details"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "查看详情"
}
},
"zh-Hant": {
"stringUnit": {
"state": "translated",
"value": "查看詳情"
}
}
}
},
"disk.refreshNote" : {
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Capacity and device status refresh every 30s"
}
},
"zh-Hans": {
"stringUnit": {
"state": "translated",
"value": "容量与设备状态每 30 秒更新"
}
},
"zh-Hant": {
"stringUnit": {
"state": "translated",
"value": "容量與裝置狀態每 30 秒更新"
}
}
}
},
"disk.write" : {
"localizations" : {
"en" : {