From 6b645dedf0b16ac63cd480a54fa4ad07fd457fdf Mon Sep 17 00:00:00 2001 From: leo12025 Date: Sat, 27 Dec 2025 20:15:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E6=8C=87?= =?UTF-8?q?=E5=BC=95=E7=AA=97=E5=8F=A3=E7=9A=84=E5=8A=A8=E7=94=BB=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E4=BB=A5=E7=AE=80=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PowerBar/PowerBarApp.swift | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/PowerBar/PowerBarApp.swift b/PowerBar/PowerBarApp.swift index 4ce98a1..c8b5727 100644 --- a/PowerBar/PowerBarApp.swift +++ b/PowerBar/PowerBarApp.swift @@ -260,11 +260,7 @@ struct MenuContent: View { window.contentView = NSHostingView(rootView: GuideView()) window.center() - // 设置初始窗口状态(透明且缩放) - window.alphaValue = 0.0 - window.setFrameOrigin(window.frame.origin) - - // 显示窗口(不可见状态) + // 显示窗口 window.makeKeyAndOrderFront(nil) // 记录已显示指引 @@ -272,24 +268,6 @@ struct MenuContent: View { // 保存窗口引用 guideWindow = window - - // 添加窗口关闭通知监听 - NotificationCenter.default.addObserver( - forName: NSWindow.willCloseNotification, - object: window, - queue: nil - ) { _ in - // 窗口关闭时清除引用 - guideWindow = nil - } - - // 执行打开动画 - NSAnimationContext.runAnimationGroup { - context in - context.duration = 0.5 - context.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut) - window.animator().alphaValue = 1.0 - } } } @@ -437,17 +415,8 @@ struct GuideView: View { // 关闭按钮 Button(action: { - // 关闭指引界面,添加关闭动画 - if let window = NSApp.keyWindow { - NSAnimationContext.runAnimationGroup { - context in - context.duration = 0.3 - context.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut) - window.animator().alphaValue = 0.0 - } completionHandler: { - window.close() - } - } + // 关闭指引界面 + NSApp.keyWindow?.close() }) { Text("开始使用") .font(.headline)