refactor(menubar): 将刷新间隔移至底栏并恢复顶部单行

This commit is contained in:
2026-11-08 15:32:08 +08:00
parent 521319ef93
commit 8821089872
8 changed files with 33 additions and 18 deletions
+11 -8
View File
@@ -139,9 +139,9 @@ struct MenuPanelView: View {
}
.frame(height: 32)
.overlay {
if panelSize.width >= 840 { pagePicker }
if panelSize.width >= 560 { pagePicker }
}
if panelSize.width < 840 { pagePicker.frame(maxWidth: .infinity).frame(height: 28) }
if panelSize.width < 560 { pagePicker.frame(maxWidth: .infinity).frame(height: 28) }
}
.frame(height: PanelLayout.headerHeight(width: panelSize.width))
.padding(.horizontal, 4)
@@ -151,24 +151,27 @@ struct MenuPanelView: View {
HStack {
Text(verbatim: HardwareIdentity.displayName)
.lineLimit(1).truncationMode(.middle)
.help(Text(verbatim: HardwareIdentity.displayName))
Spacer(minLength: 8)
HStack(spacing: 4) {
Text("panel.uptime")
MetricText(value: String(format: "%.1f h", snapshot.uptime / 3600))
}.fixedSize()
Divider().frame(height: 14)
HStack(spacing: 4) {
Image(systemName: "timer").help(Text("sampling.panel"))
IntervalControl(milliseconds: Binding(get: { metrics.sampling.panelMilliseconds }, set: { metrics.sampling.panelMilliseconds = $0 }))
}
.foregroundStyle(.primary)
.accessibilityLabel(Text("sampling.panel"))
}
.font(PanelStyle.label).foregroundStyle(.secondary)
.frame(height: 18).padding(.horizontal, 4)
.frame(height: PanelLayout.footerHeight).padding(.horizontal, 4)
}
private var controls: some View {
HStack(spacing: 8) {
HStack(spacing: 2) {
HStack(spacing: 4) {
Image(systemName: "timer").help(Text("sampling.panel"))
IntervalControl(milliseconds: Binding(get: { metrics.sampling.panelMilliseconds }, set: { metrics.sampling.panelMilliseconds = $0 }))
}.padding(.horizontal, 6).accessibilityLabel(Text("sampling.panel"))
Divider().frame(height: 18).padding(.horizontal, 3)
Button { presentation.isPinned.toggle() } label: {
Image(systemName: presentation.isPinned ? "pin.fill" : "pin")
.frame(width: 20, height: 20)
+3 -2
View File
@@ -3,7 +3,8 @@ import CoreGraphics
nonisolated enum PanelLayout {
static let baseCardHeight: CGFloat = 204
static func headerHeight(width: CGFloat) -> CGFloat { width >= 840 ? 32 : 64 }
static let footerHeight: CGFloat = 26
static func headerHeight(width: CGFloat) -> CGFloat { width >= 560 ? 32 : 64 }
static func columns(width: CGFloat) -> Int { width >= 560 ? 2 : 1 }
static func cardWidth(size: CGSize) -> CGFloat {
let count = columns(width: size.width)
@@ -24,7 +25,7 @@ nonisolated enum PanelLayout {
}
static func needsResourceScroll(size: CGSize, rows: [CGFloat]) -> Bool {
// Outer padding, common toolbar/footer, and two gaps. Process page is separate.
resourceHeight(rows: rows) > size.height - 20 - headerHeight(width: size.width) - 18 - 16
resourceHeight(rows: rows) > size.height - 20 - headerHeight(width: size.width) - footerHeight - 16
}
static func contentSize(visible: CGRect, chrome: CGSize = .zero) -> CGSize {