Skip to content

Commit c456cc5

Browse files
committed
fix: 修复 macos 中无法使用系统快捷键退出的问题
1 parent 36b61cd commit c456cc5

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

src/main/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,10 @@ app.on("before-quit", (event) => {
302302
setIsQuitting(true);
303303

304304
if (process.platform === "darwin") {
305-
const targetWin = getAvailableWindow();
306-
if (targetWin) {
305+
const windows = BrowserWindow.getAllWindows().filter((w) => !w.isDestroyed());
306+
if (windows.length > 0) {
307307
event.preventDefault();
308-
close(targetWin);
308+
windows.forEach((targetWin) => close(targetWin));
309309
}
310310
}
311311
});

src/main/menu.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { BrowserWindow, Menu } from "electron";
2-
import { close } from "./ipcBridge";
32

43
/**
54
* 获取当前聚焦的窗口,用于菜单 click 处理器。
@@ -94,11 +93,7 @@ export default function createMenu() {
9493
{ type: "separator" },
9594
{
9695
label: "退出 milkup",
97-
accelerator: "Cmd+Q",
98-
click: () => {
99-
const win = getFocusedWindow();
100-
if (win) close(win);
101-
},
96+
role: "quit",
10297
},
10398
],
10499
});

0 commit comments

Comments
 (0)