feat(menubar): 拆分紧凑双页面板并按页采样

This commit is contained in:
2026-11-08 10:42:55 +08:00
parent ac8b4a7e6a
commit 41dcc497b5
36 changed files with 465 additions and 288 deletions
@@ -42,33 +42,10 @@ extension MenuPanelView {
} else {
Text("metric.waiting").foregroundStyle(.secondary)
}
Spacer(minLength: 0)
CardSeparator()
HStack(spacing: 10) {
VStack(alignment: .leading, spacing: 4) {
HStack {
Text("cpu.load.oneMinute", tableName: "CPUDetails").foregroundStyle(.secondary)
Spacer(minLength: 3)
MetricText(
value: snapshot.load.first.map { "\(MetricFormat.decimal($0)) / \(snapshot.cpu?.cores.count ?? 0)" } ?? "--")
}
MetricProgressBar(
value: (snapshot.load.first ?? 0) / Double(max(1, snapshot.cpu?.cores.count ?? 0)), color: Color("MetricCPU")
)
.frame(height: 5).accessibilityHidden(true)
}.frame(maxWidth: .infinity)
Rectangle().fill(.primary.opacity(0.08)).frame(width: 1, height: 25)
VStack(alignment: .leading, spacing: 3) {
Text("panel.uptime").foregroundStyle(.secondary)
MetricText(value: String(format: "%.1f h", snapshot.uptime / 3600))
.fontWeight(.medium)
}
}.font(PanelStyle.label).lineLimit(1)
}
}
var gpuCard: some View {
let summary = GPUUtilizationSummary(samples: samples)
return ResourceCard(
title: "metric.gpu", symbol: "square.grid.2x2", color: Color("MetricGPU"), value: MetricFormat.percent(snapshot.gpuUsage),
status: snapshot.gpuTemperature.map { "\(Int($0.rounded()))°C" },
@@ -81,15 +58,6 @@ extension MenuPanelView {
firstLabel: "gpu.totalUtilization", secondLabel: "gpu.renderer", thirdLabel: "gpu.tiler",
expectedInterval: chartInterval, boundaryDates: chartBoundaries, intervals: chartIntervals)
CardSeparator()
gpuActivity("gpu.rendererActivity", value: snapshot.gpu?.renderer, color: Color("MetricCPU"))
gpuActivity("gpu.tilerActivity", value: snapshot.gpu?.tiler, color: Color("SeriesSystem"))
CardSeparator()
Spacer(minLength: 0)
GPUStatisticsView(
inUse: snapshot.gpu?.inUseMemory, allocated: snapshot.gpu?.allocatedMemory,
average: summary.average, peak: summary.peak
)
Spacer(minLength: 0)
let fans = displayedFans
if !fans.isEmpty {
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 10), count: min(2, fans.count)), spacing: 5) {
@@ -105,13 +73,6 @@ extension MenuPanelView {
}
}
func gpuActivity(_ title: LocalizedStringKey, value: Double?, color: Color) -> some View {
HStack(spacing: 8) {
Text(title).font(PanelStyle.label).frame(width: 100, alignment: .leading)
MetricProgressBar(value: value ?? 0, color: color).frame(height: 5)
MetricText(value: MetricFormat.percent(value)).font(PanelStyle.value).frame(width: 30, alignment: .trailing)
}.font(PanelStyle.label)
}
var memoryCard: some View {
ResourceCard(
title: "metric.memory", symbol: "memorychip", color: Color("MemoryApplication"),
@@ -235,12 +196,6 @@ extension MenuPanelView {
.font(PanelStyle.label)
.lineLimit(1)
.frame(height: 32)
Spacer(minLength: 0)
CardSeparator()
EnergyProcessSection(metrics: metrics)
// Reserve the header and all three rows before process sampling completes.
.frame(height: 74, alignment: .top)
.lineLimit(1)
}.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
}