Electron之点击左上角关闭按钮隐藏,再次打开不重新加载窗口
程序员文章站
2021-12-25 10:58:38
...
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);