feat(storage): 按容量分布与设备状态重设计存储卡片
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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" : {
|
||||
|
||||
Reference in New Issue
Block a user