Manav Rathi 1 年之前
父节点
当前提交
98c3e43b70
共有 2 个文件被更改,包括 5 次插入11 次删除
  1. 5 3
      desktop/src/main.ts
  2. 0 8
      desktop/src/main/init.ts

+ 5 - 3
desktop/src/main.ts

@@ -19,7 +19,6 @@ import {
     addAllowOriginHeader,
     handleDownloads,
     handleExternalLinks,
-    setupMacWindowOnDockIconClick,
 } from "./main/init";
 import { attachFSWatchIPCHandlers, attachIPCHandlers } from "./main/ipc";
 import log, { initLogging } from "./main/log";
@@ -243,7 +242,7 @@ const main = () => {
         return;
     }
 
-    let mainWindow: BrowserWindow;
+    let mainWindow: BrowserWindow | undefined;
 
     initLogging();
     setupRendererServer();
@@ -266,7 +265,6 @@ const main = () => {
         mainWindow = await createMainWindow();
         const watcher = initWatcher(mainWindow);
         setupTrayItem(mainWindow);
-        setupMacWindowOnDockIconClick();
         Menu.setApplicationMenu(await createApplicationMenu(mainWindow));
         attachIPCHandlers();
         attachFSWatchIPCHandlers(watcher);
@@ -284,6 +282,10 @@ const main = () => {
         }
     });
 
+    // This is a macOS only event. Show our window when the user activates the
+    // app, e.g. by clicking on its dock icon.
+    app.on("activate", () => mainWindow?.show());
+
     app.on("before-quit", () => setIsAppQuitting(true));
 };
 

+ 0 - 8
desktop/src/main/init.ts

@@ -42,14 +42,6 @@ export function getUniqueSavePath(filename: string, directory: string): string {
     return uniqueFileSavePath;
 }
 
-export function setupMacWindowOnDockIconClick() {
-    app.on("activate", function () {
-        const windows = BrowserWindow.getAllWindows();
-        // we allow only one window
-        windows[0].show();
-    });
-}
-
 function lowerCaseHeaders(responseHeaders: Record<string, string[]>) {
     const headers: Record<string, string[]> = {};
     for (const key of Object.keys(responseHeaders)) {