feat(monitors): 实现 C 阶段网络存储电池监控与三语详情

This commit is contained in:
2026-10-30 16:02:46 +08:00
parent 1cb67b86e8
commit 069e2e100f
22 changed files with 1237 additions and 13 deletions
+9
View File
@@ -11,5 +11,14 @@ nonisolated enum MetricFormat {
return String(format: "%.1f GB", Double(value) / 1_000_000_000)
}
static func rate(_ value: Double?) -> String {
guard let value, value.isFinite, value >= 0 else { return "--" }
let units = ["B/s", "KB/s", "MB/s", "GB/s", "TB/s"]
var scaled = value
var index = 0
while scaled >= 1000 && index < units.count - 1 { scaled /= 1000; index += 1 }
return String(format: "%.1f %@", scaled, units[index])
}
static func decimal(_ value: Double) -> String { String(format: "%.1f", value) }
}