From 4cf0e9e72cb5a55bef9640360a06ab9845f6e569 Mon Sep 17 00:00:00 2001 From: tigerenwork Date: Mon, 12 Oct 2026 10:56:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(AppDelegate):=20=E5=85=B3=E9=97=AD=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E6=97=B6=E4=BF=9D=E6=8C=81=E5=BA=94=E7=94=A8=E8=BF=90?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 作为菜单栏应用,点击窗口关闭按钮不应退出程序,否则轮询与通知会停止。 applicationShouldTerminateAfterLastWindowClosed 返回 false;退出仅通过 弹层 Quit 按钮或 Cmd+Q。 --- Sources/AppDelegate.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sources/AppDelegate.swift b/Sources/AppDelegate.swift index 5cf8caf..d13506c 100644 --- a/Sources/AppDelegate.swift +++ b/Sources/AppDelegate.swift @@ -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 {