mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-07 15:08:24 +00:00
Behave like a single-window Mac app on Mac
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
const {app, BrowserWindow} = require('electron');
|
const {app, BrowserWindow} = require('electron');
|
||||||
|
|
||||||
let mainWindow = null;
|
let mainWindow = null;
|
||||||
|
let appQuitting = false;
|
||||||
|
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
@@ -12,8 +13,26 @@ app.on('ready', () => {
|
|||||||
mainWindow.on('closed', () => {
|
mainWindow.on('closed', () => {
|
||||||
mainWindow = null;
|
mainWindow = null;
|
||||||
});
|
});
|
||||||
|
mainWindow.on('close', (e) => {
|
||||||
|
if (process.platform == 'darwin' && !appQuitting) {
|
||||||
|
// On Mac, closing the window just hides it
|
||||||
|
// (this is generally how single-window Mac apps
|
||||||
|
// behave, eg. Mail.app)
|
||||||
|
e.preventDefault();
|
||||||
|
mainWindow.hide();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
app.on('window-all-closed', () => {
|
||||||
app.quit();
|
app.quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.on('activate', () => {
|
||||||
|
mainWindow.show();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on('before-quit', () => {
|
||||||
|
appQuitting = true;
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user