feat(menubar): 实现紧凑独立双列与按内容定高
This commit is contained in:
@@ -34,7 +34,6 @@ extension MenuPanelView {
|
||||
boundaryDates: chartBoundaries, intervals: chartIntervals)
|
||||
CardSeparator()
|
||||
if let cpu = snapshot.cpu {
|
||||
Spacer(minLength: 0)
|
||||
CPUCoreGrid(
|
||||
values: cpu.cores, kinds: CPUCoreTopology.cores, interval: chartInterval,
|
||||
availableWidth: cardContentWidth)
|
||||
@@ -57,18 +56,24 @@ extension MenuPanelView {
|
||||
color: Color("MetricGPU"), secondColor: Color("MetricCPU"), thirdColor: Color("SeriesSystem"),
|
||||
firstLabel: "gpu.totalUtilization", secondLabel: "gpu.renderer", thirdLabel: "gpu.tiler",
|
||||
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals)
|
||||
CardSeparator()
|
||||
let fans = displayedFans
|
||||
if !fans.isEmpty {
|
||||
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 10), count: min(2, fans.count)), spacing: 5) {
|
||||
CardSeparator()
|
||||
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 10), count: min(2, fans.count)), spacing: 4) {
|
||||
ForEach(fans) { fan in
|
||||
FanSpeedIndicator(
|
||||
title: fans.count == 2
|
||||
? (fan.id == 0 ? Text("gpu.fanLeft") : Text("gpu.fanRight"))
|
||||
: Text("gpu.fanNumber \(fan.id + 1)"), rpm: fan.rpm)
|
||||
.frame(height: 16)
|
||||
}
|
||||
}
|
||||
.modifier(CardInset())
|
||||
} else if snapshot.fans == nil {
|
||||
CardSeparator()
|
||||
Text("metric.waiting").font(PanelStyle.label)
|
||||
.frame(maxWidth: .infinity, alignment: .leading).frame(height: 16)
|
||||
.modifier(CardInset())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,7 +83,8 @@ extension MenuPanelView {
|
||||
title: "metric.memory", symbol: "memorychip", color: Color("MemoryApplication"),
|
||||
value: snapshot.memory.map {
|
||||
String(format: "%.1f / %.0f GiB", Double($0.used) / 1_073_741_824, Double($0.total) / 1_073_741_824)
|
||||
} ?? "--"
|
||||
} ?? "--",
|
||||
status: snapshot.memory.map { MetricFormat.percent($0.usage) }
|
||||
) {
|
||||
PanelTrendChart(
|
||||
dates: samples.map(\.date),
|
||||
@@ -134,6 +140,7 @@ extension MenuPanelView {
|
||||
Text("panel.apfsScope").font(.system(size: 9)).foregroundStyle(.secondary)
|
||||
}
|
||||
}.padding(12).frame(width: 330)
|
||||
.environment(\.locale, locale)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -163,7 +170,7 @@ extension MenuPanelView {
|
||||
batteryDetails(battery)
|
||||
} else {
|
||||
Text(snapshot.batteryState == .absent ? "panel.noBattery" : "panel.batteryFailed").foregroundStyle(.secondary)
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
.font(PanelStyle.label).frame(maxWidth: .infinity).frame(height: 32)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,7 +206,7 @@ extension MenuPanelView {
|
||||
.lineLimit(1)
|
||||
.frame(height: 32)
|
||||
|
||||
}.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
}.frame(maxWidth: .infinity, alignment: .topLeading)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user