OS Xではメインウィンドウを閉じる代わりに隠し、ドックアイコンをクリックした時に再表示する
This commit is contained in:
26
main.js
26
main.js
@@ -26,6 +26,15 @@ app.on('browser-window-created', function(event, window){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// For OSX, show hidden mainWindow when clicking dock icon.
|
||||||
|
app.on('activate', function(event){
|
||||||
|
mainWindow.show();
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on('before-quit', function(){
|
||||||
|
willAppQuit = true;
|
||||||
|
})
|
||||||
|
|
||||||
// This method will be called when Electron has finished
|
// This method will be called when Electron has finished
|
||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
app.on('ready', function() {
|
app.on('ready', function() {
|
||||||
@@ -39,11 +48,17 @@ app.on('ready', function() {
|
|||||||
// mainWindow.openDevTools();
|
// mainWindow.openDevTools();
|
||||||
|
|
||||||
mainWindow.on('close', function(event){
|
mainWindow.on('close', function(event){
|
||||||
// Minimize the window for close button.
|
// Minimize or hide the window for close button.
|
||||||
if(process.platform==='win32'){
|
if(!willAppQuit){ // avoid [Ctrl|Cmd]+Q
|
||||||
if(!willAppQuit){ // for Ctrl+Q
|
event.preventDefault();
|
||||||
event.preventDefault();
|
switch (process.platform) {
|
||||||
mainWindow.minimize();
|
case 'win32':
|
||||||
|
mainWindow.minimize();
|
||||||
|
break;
|
||||||
|
case 'darwin':
|
||||||
|
mainWindow.hide();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -63,7 +78,6 @@ app.on('ready', function() {
|
|||||||
label: 'Quit',
|
label: 'Quit',
|
||||||
accelerator: 'Ctrl + Q',
|
accelerator: 'Ctrl + Q',
|
||||||
click: function(item, focusedWindow){
|
click: function(item, focusedWindow){
|
||||||
willAppQuit = true;
|
|
||||||
app.quit();
|
app.quit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user