Browse Source

修复 mac 下在 dock 右键菜单中无法退出的问题。

oldj 10 years ago
parent
commit
fe42890d4e
1 changed files with 4 additions and 4 deletions
  1. 4 4
      app/main.js

+ 4 - 4
app/main.js

@@ -37,12 +37,14 @@ app.on('ready', function () {
 
     // and load the index.html of the app.
     mainWindow.loadURL('file://' + __dirname + '/index.html');
+    //app.dock.hide();
 
     if (app.__is_debug) {
         mainWindow.toggleDevTools();
     }
 
     mainWindow.on('close', function (e) {
+        console.log('close');
         if (!app.__force_quit) {
             e.preventDefault();
             mainWindow.hide();
@@ -51,11 +53,9 @@ app.on('ready', function () {
 
     // You can use 'before-quit' instead of (or with) the close event
     app.on('before-quit', function (e) {
+        console.log('before-quit');
         // Handle menu-item or keyboard shortcut quit here
-        if (!app.__force_quit) {
-            e.preventDefault();
-            mainWindow.hide();
-        }
+        app.__force_quit = true;
     });
 
     // Remove mainWindow.on('closed'), as it is redundant