Skip to content

Commit 2959737

Browse files
authored
Merge pull request #623 from Beriholic/dev
🐞 fix: 修复Mac使用快捷键退出异常
2 parents 078e368 + 7accb0a commit 2959737

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

electron/main/windows/main-window.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BrowserWindow, shell } from "electron";
1+
import { BrowserWindow, shell, app } from "electron";
22
import { createWindow } from "./index";
33
import { mainWinUrl } from "../utils/config";
44
import { useStore } from "../store";
@@ -7,8 +7,13 @@ import { isLinux } from "../utils/config";
77
class MainWindow {
88
private win: BrowserWindow | null = null;
99
private winURL: string;
10+
private isQuitting: boolean = false;
1011
constructor() {
1112
this.winURL = mainWinUrl;
13+
14+
app.on("before-quit", () => {
15+
this.isQuitting = true;
16+
});
1217
}
1318
/**
1419
* 保存窗口大小和状态
@@ -83,6 +88,9 @@ class MainWindow {
8388
}
8489
// 窗口关闭
8590
this.win?.on("close", (event) => {
91+
if (this.isQuitting) {
92+
return;
93+
}
8694
event.preventDefault();
8795
this.win?.hide();
8896
});

0 commit comments

Comments
 (0)