mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 12:23:24 +02:00
create new window if closed when dock icon clicked
This commit is contained in:
parent
25666577f4
commit
12bb2c1b7a
1 changed files with 47 additions and 42 deletions
|
@ -25,14 +25,53 @@ var path = require('path');
|
|||
var TRAY_ICON = path.join(__dirname, '../resources/console-tray.png');
|
||||
var APP_ICON = path.join(__dirname, '../resources/console.png');
|
||||
|
||||
// Quit when all windows are closed.
|
||||
app.on('window-all-closed', function() {
|
||||
// On OS X it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
if (process.platform != 'darwin') {
|
||||
app.quit();
|
||||
// Don't quit when all windows are closed, make user explicitly quit from tray
|
||||
app.on('window-all-closed', function() {});
|
||||
|
||||
function createNewWindow() {
|
||||
// Create the browser window.
|
||||
mainWindow = new BrowserWindow({
|
||||
title: "High Fidelity",
|
||||
width: 970,
|
||||
height: 775,
|
||||
icon: APP_ICON,
|
||||
resizable: false
|
||||
});
|
||||
|
||||
// In debug mode, keep the menu bar, but auto-hide it so the UI still looks the same.
|
||||
if (debug) {
|
||||
mainWindow.setAutoHideMenuBar(true);
|
||||
} else {
|
||||
mainWindow.setMenu(null);
|
||||
}
|
||||
});
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadURL('file://' + __dirname + '/index.html');
|
||||
|
||||
// Open the DevTools.
|
||||
mainWindow.webContents.openDevTools();
|
||||
|
||||
// Emitted when the window is closed.
|
||||
mainWindow.on('closed', function() {
|
||||
// Dereference the window object, usually you would store windows
|
||||
// in an array if your app supports multi windows, this is the time
|
||||
// when you should delete the corresponding element.
|
||||
mainWindow = null;
|
||||
});
|
||||
|
||||
// When a link is clicked that has `_target="_blank"`, open it in the user's native browser
|
||||
mainWindow.webContents.on('new-window', function(e, url) {
|
||||
e.preventDefault();
|
||||
shell.openExternal(url);
|
||||
});
|
||||
}
|
||||
|
||||
// When a user clicks on dock icon, re-create the window if we don't have one
|
||||
app.on('activate', function(){
|
||||
if (!mainWindow) {
|
||||
createNewWindow();
|
||||
}
|
||||
})
|
||||
|
||||
// Check command line arguments to see how to find binaries
|
||||
var argv = require('yargs').argv;
|
||||
|
@ -81,41 +120,7 @@ app.on('ready', function() {
|
|||
// Require electron-compile to use LESS files in place of basic CSS
|
||||
require('electron-compile').init();
|
||||
|
||||
// Create the browser window.
|
||||
mainWindow = new BrowserWindow({
|
||||
title: "High Fidelity",
|
||||
width: 970,
|
||||
height: 775,
|
||||
icon: APP_ICON,
|
||||
resizable: false
|
||||
});
|
||||
|
||||
// In debug mode, keep the menu bar, but auto-hide it so the UI still looks the same.
|
||||
if (debug) {
|
||||
mainWindow.setAutoHideMenuBar(true);
|
||||
} else {
|
||||
mainWindow.setMenu(null);
|
||||
}
|
||||
|
||||
// and load the index.html of the app.
|
||||
mainWindow.loadURL('file://' + __dirname + '/index.html');
|
||||
|
||||
// Open the DevTools.
|
||||
mainWindow.webContents.openDevTools();
|
||||
|
||||
// Emitted when the window is closed.
|
||||
mainWindow.on('closed', function() {
|
||||
// Dereference the window object, usually you would store windows
|
||||
// in an array if your app supports multi windows, this is the time
|
||||
// when you should delete the corresponding element.
|
||||
mainWindow = null;
|
||||
});
|
||||
|
||||
// When a link is clicked that has `_target="_blank"`, open it in the user's native browser
|
||||
mainWindow.webContents.on('new-window', function(e, url) {
|
||||
e.preventDefault();
|
||||
shell.openExternal(url);
|
||||
});
|
||||
createNewWindow();
|
||||
|
||||
var logPath = path.join(app.getAppPath(), 'logs');
|
||||
|
||||
|
|
Loading…
Reference in a new issue