fix(AppDelegate): 关闭窗口时保持应用运行
作为菜单栏应用,点击窗口关闭按钮不应退出程序,否则轮询与通知会停止。 applicationShouldTerminateAfterLastWindowClosed 返回 false;退出仅通过 弹层 Quit 按钮或 Cmd+Q。
This commit is contained in:
parent
a29010fd51
commit
4cf0e9e72c
|
|
@ -36,6 +36,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
}
|
||||
}
|
||||
|
||||
// MARK: - NSApplicationDelegate
|
||||
|
||||
/// Bugger is a menu-bar app: closing a window must not quit it, otherwise
|
||||
/// polling and notifications would stop. Quit only via the Quit button
|
||||
/// or Cmd+Q.
|
||||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
false
|
||||
}
|
||||
|
||||
private func setupStatusItem() {
|
||||
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
|
||||
if let button = statusItem.button {
|
||||
|
|
|
|||
Loading…
Reference in New Issue