Skip to content

Commit f69481b

Browse files
committed
🐞 fix: 修复Mac使用快捷键退出异常
1 parent 113d39a commit f69481b

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

electron/main/windows/main-window.ts

Lines changed: 10 additions & 2 deletions
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
* 保存窗口大小和状态
@@ -82,7 +87,10 @@ class MainWindow {
8287
});
8388
}
8489
// 窗口关闭
85-
this.win?.on("close", (event) => {
90+
this.win?.on("close", async (event) => {
91+
if (this.isQuitting) {
92+
return;
93+
}
8694
event.preventDefault();
8795
this.win?.hide();
8896
});

0 commit comments

Comments
 (0)