feat(memory): 重设计内存卡片并统一二进制容量单位

This commit is contained in:
2026-11-03 16:51:14 +08:00
parent cc38066de2
commit 90ed18e6ac
11 changed files with 186 additions and 17 deletions
+4
View File
@@ -4,6 +4,7 @@ enum TrendValueFormat {
case percent
case rate
case bytes
case memory
case watts
}
@@ -19,6 +20,7 @@ struct PanelTrendChart: View {
var fixedScale: Double? = 1
var scaleLabel: String?
var secondSeriesUsesAutonomousScale = false
var firstValueFormat: TrendValueFormat?
var secondValueFormat: TrendValueFormat?
var firstLabel: LocalizedStringKey = "panel.total"
var secondLabel: LocalizedStringKey = "network.upload"
@@ -51,6 +53,7 @@ struct PanelTrendChart: View {
private var secondaryScale: Double { max(0.0001, retainedSecondScale) }
private var hasSecondaryScale: Bool { secondSeriesUsesAutonomousScale && !second.isEmpty }
private var automaticFormat: TrendValueFormat {
if let firstValueFormat { return firstValueFormat }
if fixedScale == 1 { return .percent }
if fixedScale == nil { return .rate }
return .bytes
@@ -66,6 +69,7 @@ struct PanelTrendChart: View {
case .percent: return MetricFormat.percent(value)
case .rate: return MetricFormat.rate(value)
case .bytes: return MetricFormat.bytes(UInt64(max(0, value)))
case .memory: return MetricFormat.memory(UInt64(max(0, value)))
case .watts: return MetricFormat.watts(value)
}
}