perf(efficiency): 接入真实CPU能量并隔离展示与采样需求

This commit is contained in:
2026-11-04 01:11:24 +08:00
parent a96d188abe
commit 1c26fc18f3
37 changed files with 1249 additions and 179 deletions
+9 -4
View File
@@ -54,8 +54,8 @@ struct MenuPanelView: View {
} else {
resourceRows
}
if metrics.isPanelVisible && PanelResourceAudit.omitted != "processes" {
ProcessTableView(snapshot: snapshot.processes, wide: panelSize.width >= 900).frame(maxWidth: .infinity, maxHeight: .infinity)
if presentation.isOpen && PanelResourceAudit.omitted != "processes" {
PanelProcessSection(metrics: metrics, wide: panelSize.width >= 900).frame(maxWidth: .infinity, maxHeight: .infinity)
.frame(minHeight: 170)
}
}
@@ -65,13 +65,11 @@ struct MenuPanelView: View {
if panelSize != size { panelSize = size }
}.frame(width: 0, height: 0))
.onAppear {
metrics.setPanelVisible(true)
reservedFanCount = snapshot.fans?.count ?? 0
}
.onChange(of: snapshot.fans?.count) { _, count in
reservedFanCount = max(reservedFanCount, count ?? 0)
}
.onDisappear { metrics.setPanelVisible(false) }
.onChange(of: snapshot.network?.map(\.identity)) { _, keys in
if !selectedInterface.isEmpty && !(keys ?? []).contains(selectedInterface) { selectedInterface = "" }
}
@@ -215,3 +213,10 @@ private struct PanelControlButtonBody<Content: View>: View {
.onHover { isHovered = $0 }
}
}
/// Keep process publications out of the resource-card observation scope.
private struct PanelProcessSection: View {
let metrics: MetricsStore
let wide: Bool
var body: some View { ProcessTableView(snapshot: metrics.processSnapshot, wide: wide) }
}