perf(ui): 移除监控动效并精简原生图表绘制
This commit is contained in:
@@ -28,7 +28,7 @@ struct GPUStatisticsView: View {
|
||||
HStack(spacing: 4) {
|
||||
Text(title).foregroundStyle(.secondary)
|
||||
Spacer(minLength: 0)
|
||||
AnimatedMetricText(value: MetricFormat.bytes(bytes)).font(PanelStyle.value)
|
||||
MetricText(value: MetricFormat.bytes(bytes)).font(PanelStyle.value)
|
||||
}.font(PanelStyle.label).lineLimit(1)
|
||||
MetricProgressBar(value: bytes.map { Double($0) / reference } ?? 0, color: color)
|
||||
.frame(height: 3)
|
||||
|
||||
@@ -22,11 +22,11 @@ struct MemoryDetailsView: View {
|
||||
CardField(title: "memory.pressure") { pressure }
|
||||
Divider().frame(height: 32)
|
||||
CardField(title: "memory.cached") {
|
||||
AnimatedMetricText(value: MetricFormat.memory(memory.cached))
|
||||
MetricText(value: MetricFormat.memory(memory.cached))
|
||||
}
|
||||
Divider().frame(height: 32)
|
||||
CardField(title: "memory.swap") {
|
||||
AnimatedMetricText(value: MetricFormat.memory(memory.swapUsed))
|
||||
MetricText(value: MetricFormat.memory(memory.swapUsed))
|
||||
}
|
||||
}.font(PanelStyle.label).lineLimit(1)
|
||||
}
|
||||
|
||||
@@ -24,19 +24,16 @@ import Observation
|
||||
private let visibility: (Bool) -> Void
|
||||
private let menuTitle: (String) -> String
|
||||
private let openSettings: () -> Void
|
||||
private let reducedMotion: () -> Bool
|
||||
private var showingStatusMenu = false
|
||||
private var isHiding = false
|
||||
|
||||
init<Content: View>(installStatusItem: Bool = true, visibility: @escaping (Bool) -> Void,
|
||||
menuTitle: @escaping (String) -> String = { $0 },
|
||||
openSettings: @escaping () -> Void = {},
|
||||
reducedMotion: @escaping () -> Bool = { false },
|
||||
@ViewBuilder content: @escaping (PanelPresentation) -> Content) {
|
||||
self.visibility = visibility
|
||||
self.menuTitle = menuTitle
|
||||
self.openSettings = openSettings
|
||||
self.reducedMotion = reducedMotion
|
||||
self.content = {
|
||||
let host = NSHostingView(rootView: content($0))
|
||||
// The controller owns the fixed panel frame; content must not negotiate window limits.
|
||||
@@ -48,7 +45,8 @@ import Observation
|
||||
panel.isReleasedWhenClosed = false
|
||||
panel.isOpaque = false
|
||||
panel.backgroundColor = .clear
|
||||
panel.hasShadow = true
|
||||
panel.hasShadow = false
|
||||
panel.animationBehavior = .none
|
||||
panel.hidesOnDeactivate = false
|
||||
panel.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
|
||||
panel.dismiss = { [weak self] in self?.hide() }
|
||||
@@ -115,12 +113,7 @@ import Observation
|
||||
return window.convertToScreen(button.convert(button.bounds, to: nil)).contains(screenPoint)
|
||||
}
|
||||
|
||||
private func applyWindowMotion() {
|
||||
panel.animationBehavior = reducedMotion() || NSWorkspace.shared.accessibilityDisplayShouldReduceMotion ? .none : .default
|
||||
}
|
||||
|
||||
func show() {
|
||||
applyWindowMotion()
|
||||
guard !panel.isVisible else { panel.makeKeyAndOrderFront(nil); return }
|
||||
place()
|
||||
presentation.isOpen = true
|
||||
@@ -144,7 +137,6 @@ import Observation
|
||||
isHiding = true
|
||||
defer { isHiding = false }
|
||||
presentation.isOpen = false
|
||||
applyWindowMotion()
|
||||
panel.orderOut(nil)
|
||||
#if DEBUG || KYMO_AUDIT
|
||||
if let content = panel.contentView { lastHiddenContent = content }
|
||||
|
||||
@@ -74,7 +74,7 @@ extension MenuPanelView {
|
||||
CardField(title: title) {
|
||||
HStack(spacing: 3) {
|
||||
Image(systemName: symbol).foregroundStyle(color)
|
||||
AnimatedMetricText(value: value)
|
||||
MetricText(value: value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ extension MenuPanelView {
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Text(key).font(PanelStyle.label).foregroundStyle(.secondary)
|
||||
Spacer(minLength: 6)
|
||||
AnimatedMetricText(value: value).font(PanelStyle.value)
|
||||
MetricText(value: value).font(PanelStyle.value)
|
||||
}.frame(height: 14)
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ extension MenuPanelView {
|
||||
HStack {
|
||||
Text("cpu.load.oneMinute", tableName: "CPUDetails").foregroundStyle(.secondary)
|
||||
Spacer(minLength: 3)
|
||||
AnimatedMetricText(
|
||||
MetricText(
|
||||
value: snapshot.load.first.map { "\(MetricFormat.decimal($0)) / \(snapshot.cpu?.cores.count ?? 0)" } ?? "--")
|
||||
}
|
||||
MetricProgressBar(
|
||||
@@ -60,7 +60,7 @@ extension MenuPanelView {
|
||||
Rectangle().fill(.primary.opacity(0.08)).frame(width: 1, height: 25)
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
Text("panel.uptime").foregroundStyle(.secondary)
|
||||
AnimatedMetricText(value: String(format: "%.1f h", snapshot.uptime / 3600))
|
||||
MetricText(value: String(format: "%.1f h", snapshot.uptime / 3600))
|
||||
.fontWeight(.medium)
|
||||
}
|
||||
}.font(PanelStyle.label).lineLimit(1)
|
||||
@@ -109,7 +109,7 @@ extension MenuPanelView {
|
||||
HStack(spacing: 8) {
|
||||
Text(title).font(PanelStyle.label).frame(width: 100, alignment: .leading)
|
||||
MetricProgressBar(value: value ?? 0, color: color).frame(height: 5)
|
||||
AnimatedMetricText(value: MetricFormat.percent(value)).font(PanelStyle.value).frame(width: 30, alignment: .trailing)
|
||||
MetricText(value: MetricFormat.percent(value)).font(PanelStyle.value).frame(width: 30, alignment: .trailing)
|
||||
}.font(PanelStyle.label)
|
||||
}
|
||||
var memoryCard: some View {
|
||||
@@ -225,7 +225,7 @@ extension MenuPanelView {
|
||||
if battery.externalPower {
|
||||
Text("battery.timeNotApplicable").font(PanelStyle.value)
|
||||
} else if let minutes = battery.minutesRemaining {
|
||||
AnimatedMetricText(value: "\(minutes) min").font(PanelStyle.value)
|
||||
MetricText(value: "\(minutes) min").font(PanelStyle.value)
|
||||
} else {
|
||||
Text("battery.timeUnknown").font(PanelStyle.value)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ struct MenuPanelView: View {
|
||||
var presentation = PanelPresentation()
|
||||
var onOpenSettings: () -> Void = {}
|
||||
@Environment(\.locale) var locale
|
||||
@Environment(\.accessibilityReduceMotion) var reduceMotion
|
||||
@State private var panelSize = PanelLayout.contentSize(visible: NSScreen.main?.visibleFrame ?? CGRect(x: 0, y: 0, width: 1000, height: 760))
|
||||
@State var selectedInterface = ""
|
||||
@State var publicIPAddress: String?
|
||||
@@ -75,9 +74,7 @@ struct MenuPanelView: View {
|
||||
}
|
||||
.background(Color("PanelBackground"), in: .rect(cornerRadius: 18))
|
||||
.clipShape(.rect(cornerRadius: 18))
|
||||
.environment(\.metricAnimationsEnabled, MetricMotionPolicy.enabled(
|
||||
reduced: preferences.reduceMotion, systemReduced: reduceMotion, visible: metrics.isPanelVisible,
|
||||
paused: metrics.isPaused, sleeping: metrics.isSystemSleeping || metrics.isDisplaySleeping))
|
||||
.transaction { $0.animation = nil; $0.disablesAnimations = true }
|
||||
.modifier(AppearanceStyle(preferences: preferences))
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ import AppKit
|
||||
hoveredPlots: views.filter { $0.input?.hoveredIndex != nil }.count, nativePlots: views.count,
|
||||
pointerInsidePanel: controller.panel.isVisible && controller.panel.frame.contains(NSEvent.mouseLocation),
|
||||
plotBounds: views.map { [Double($0.bounds.width), Double($0.bounds.height)] },
|
||||
animatedPlots: views.filter { $0.input?.animates == true }.count)
|
||||
animatedPlots: 0)
|
||||
if event == "open1.10", ProcessInfo.processInfo.environment["KYMO_AUDIT_CAPTURE"] == "1",
|
||||
let content = controller.panel.contentView { capture(content) }
|
||||
}
|
||||
|
||||
@@ -20,11 +20,11 @@ struct StorageDetailsView: View {
|
||||
CardSeparator()
|
||||
HStack(alignment: .top, spacing: 8) {
|
||||
CardField(title: "disk.remainingLife") {
|
||||
AnimatedMetricText(value: MetricFormat.percent(health?.remainingLife))
|
||||
MetricText(value: MetricFormat.percent(health?.remainingLife))
|
||||
}
|
||||
Divider().frame(height: 32)
|
||||
CardField(title: "disk.powerOnHours") {
|
||||
AnimatedMetricText(value: health?.powerOnHours.map { "\($0) h" } ?? "--")
|
||||
MetricText(value: health?.powerOnHours.map { "\($0) h" } ?? "--")
|
||||
}
|
||||
Divider().frame(height: 32)
|
||||
CardField(title: "disk.localVolumes") {
|
||||
|
||||
@@ -33,6 +33,7 @@ struct AppearanceSettingsView: View {
|
||||
.frame(width: 520)
|
||||
.frame(minHeight: 420, idealHeight: 460)
|
||||
.modifier(AppearanceStyle(preferences: preferences, refreshContentOnChange: true))
|
||||
.transaction { $0.animation = nil; $0.disablesAnimations = true }
|
||||
}
|
||||
|
||||
private var generalPage: some View {
|
||||
@@ -62,10 +63,6 @@ struct AppearanceSettingsView: View {
|
||||
.tint(.primary)
|
||||
}
|
||||
}
|
||||
Section {
|
||||
Toggle("motion.reduce", isOn: $preferences.reduceMotion)
|
||||
Text("motion.help").font(.callout).foregroundStyle(.secondary)
|
||||
}
|
||||
Section {
|
||||
Toggle("sampling.backgroundEnabled", isOn: $sampling.backgroundEnabled)
|
||||
LabeledContent("sampling.background") {
|
||||
|
||||
Reference in New Issue
Block a user