轉(zhuǎn)自https://github.com/writefreely/writefreely-swiftui-multiplatform
func applicationDidBecomeActive(_ notification: Notification) {
if let window = NSApp.windows.first {
window.deminiaturize(nil)
}
}
func applicationDidChangeOcclusionState(_ notification: Notification) {
if let window = NSApp.windows.first, window.isMiniaturized {
NSWorkspace.shared.runningApplications.first(where: {
$0.activationPolicy == .regular
})?.activate(options: .activateAllWindows)
}
}