From 3aa687abd3b3cfed2accaea46c760d0c62ee0c04 Mon Sep 17 00:00:00 2001 From: William Date: Tue, 30 Jun 2026 09:01:24 +0600 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=9C=AA=E6=AD=A3=E7=A1=AE=E6=BF=80=E6=B4=BB?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E8=BE=93=E5=85=A5=E7=A9=BF=E9=80=8F=E5=88=B0?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=E5=BA=94=E7=94=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 启动时强制激活应用并设置 key window --- .../Sources/VODManager/VODManagerApp.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/apps/macos/VODManager/Sources/VODManager/VODManagerApp.swift b/apps/macos/VODManager/Sources/VODManager/VODManagerApp.swift index 1363755..3bcc808 100644 --- a/apps/macos/VODManager/Sources/VODManager/VODManagerApp.swift +++ b/apps/macos/VODManager/Sources/VODManager/VODManagerApp.swift @@ -3,6 +3,8 @@ import SwiftData @main struct VODManagerApp: App { + @NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate + var body: some Scene { WindowGroup { ContentView() @@ -15,3 +17,16 @@ struct VODManagerApp: App { } } } + +class AppDelegate: NSObject, NSApplicationDelegate { + func applicationDidFinishLaunching(_ notification: Notification) { + NSApp.activate(ignoringOtherApps: true) + if let window = NSApp.windows.first { + window.makeKeyAndOrderFront(nil) + } + } + + func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +}