62 lines
1.7 KiB
JavaScript
62 lines
1.7 KiB
JavaScript
var app = require('electron').app; // Module to control application life.
|
|
//var BrowserWindow = require('browser-window'); // Module to create native browser window
|
|
var BrowserWindow = require('electron').BrowserWindow;
|
|
|
|
var Menu = require('electron').menu;
|
|
var isDev = process.env.NODE_ENV === 'development';
|
|
var Util = require('./'+(isDev ? 'src': 'dist')+'/util');
|
|
|
|
var mainWindow = null;
|
|
|
|
// Set log level to "debug" if NODE_ENV==devlopment
|
|
if(isDev) Util.Logger.level = 'debug';
|
|
|
|
// Quit when all windows are closed.
|
|
app.on('window-all-closed', function() {
|
|
app.quit();
|
|
});
|
|
|
|
app.on('ready', function() {
|
|
// Create the browser window.
|
|
var electronScreen = require('electron').screen;
|
|
var workArea = electronScreen.getPrimaryDisplay().workArea;
|
|
|
|
var asDesktop = process.env.PITAYA_AS_DESKTOP == 1;
|
|
|
|
mainWindow = new BrowserWindow({
|
|
type: asDesktop ? 'desktop' : undefined,
|
|
'skip-taskbar': asDesktop,
|
|
frame: !asDesktop,
|
|
width: asDesktop ? workArea.width : undefined,
|
|
height: asDesktop ? workArea.height : undefined,
|
|
'auto-hide-menu-bar': true,
|
|
x: asDesktop ? workArea.x : undefined,
|
|
y: asDesktop ? workArea.y : undefined,
|
|
});
|
|
|
|
if(isDev) {
|
|
mainWindow.openDevTools();
|
|
}
|
|
|
|
// and load the index.html of the app.
|
|
mainWindow.loadURL('file://' + __dirname + '/index.html');
|
|
|
|
mainWindow.on('closed', function() {
|
|
mainWindow = null;
|
|
});
|
|
|
|
mainWindow.on('blur', function() {
|
|
Util.Logger.debug('Focus loosed.');
|
|
});
|
|
|
|
mainWindow.on('focus', function() {
|
|
Util.Logger.debug('Focus gained.');
|
|
mainWindow.show();
|
|
});
|
|
|
|
});
|
|
|
|
process.on('exit', function(code) {
|
|
Util.Logger.info('Exiting with code "%s"', code || 0);
|
|
});
|