Mac下electron之点击左上角关闭按钮隐藏,再次打开不重新加载窗口

本文出处:https://blog.csdn.net/qq_33040483/article/details/103026442
此作笔记以备用

const electron = require('electron');
const app = electron.app;
 
let willQuitApp = false;
let window;
 
app.on('ready', () => {
  window = new electron.BrowserWindow();
 
  window.on('close', (e) => {
    if (willQuitApp) {
      window = null;
    } else {
      e.preventDefault();
      window.hide();
    }
  });
 
  window.loadURL('foobar');
});
 
app.on('activate', () => window.show());
 
app.on('before-quit', () => willQuitApp = true);


你可能感兴趣的:(Mac下electron之点击左上角关闭按钮隐藏,再次打开不重新加载窗口)