fix: 修复应用窗口未正确激活导致输入穿透到后台应用的问题
CI / lint-and-build (push) Has been cancelled

- 启动时强制激活应用并设置 key window
This commit is contained in:
2026-06-30 09:01:24 +06:00
parent 63d9d08141
commit 3aa687abd3
@@ -3,6 +3,8 @@ import SwiftData
@main @main
struct VODManagerApp: App { struct VODManagerApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene { var body: some Scene {
WindowGroup { WindowGroup {
ContentView() 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
}
}