refactor(menubar): 精简内存卡片并对齐双列底部
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import SwiftUI
|
||||
|
||||
/// Presentation only: reuse the current snapshot without additional sampling on hover.
|
||||
struct MemoryHeaderInfo {
|
||||
let memory: MemoryMetrics?
|
||||
let locale: Locale
|
||||
var bundle: Bundle = .main
|
||||
|
||||
private var pressure: (key: String?, color: Color) {
|
||||
switch memory?.pressure {
|
||||
case 1: ("pressure.normal", Color("MetricCPU"))
|
||||
case 2: ("pressure.warning", .orange)
|
||||
case 4: ("pressure.critical", .red)
|
||||
default: (nil, .secondary)
|
||||
}
|
||||
}
|
||||
|
||||
var title: String { pressure.key.map(localized) ?? "--" }
|
||||
var color: Color { pressure.color }
|
||||
var help: String {
|
||||
"\(localized("memory.pressure")): \(title)\n"
|
||||
+ "\(localized("memory.cached")): \(MetricFormat.memory(memory?.cached))\n"
|
||||
+ "\(localized("memory.swap")): \(MetricFormat.memory(memory?.swapUsed))"
|
||||
}
|
||||
|
||||
private func localized(_ key: String) -> String { AppLocalization.string(key, locale: locale, bundle: bundle) }
|
||||
}
|
||||
Reference in New Issue
Block a user