2019-07-16 06:59:35 +00:00
|
|
|
const { app, BrowserWindow } = require('electron');
|
2018-07-29 11:50:44 +00:00
|
|
|
const setupMenu = require('./menu');
|
|
|
|
|
2019-07-16 06:59:35 +00:00
|
|
|
let mainWindow;
|
|
|
|
let winURL;
|
2018-07-29 11:50:44 +00:00
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== 'development') {
|
2019-07-16 06:59:35 +00:00
|
|
|
global.__static = require('path')
|
2019-09-03 09:43:16 +00:00
|
|
|
.join(__dirname, '/static')
|
2019-07-16 06:59:35 +00:00
|
|
|
.replace(/\\/g, '\\\\');
|
2019-09-03 09:43:16 +00:00
|
|
|
global.documentsPath = app.getPath('documents');
|
2018-07-29 11:50:44 +00:00
|
|
|
}
|
|
|
|
|
2018-10-24 17:08:51 +00:00
|
|
|
if (process.env.NODE_ENV === 'development') {
|
2019-07-16 06:59:35 +00:00
|
|
|
const { getAppConfig } = require('frappejs/webpack/utils');
|
2018-10-24 17:08:51 +00:00
|
|
|
const appConfig = getAppConfig();
|
|
|
|
winURL = `http://localhost:${appConfig.dev.devServerPort}`;
|
|
|
|
} else {
|
|
|
|
winURL = `file://${__dirname}/index.html`;
|
|
|
|
}
|
2018-07-29 11:50:44 +00:00
|
|
|
|
|
|
|
function createWindow() {
|
|
|
|
/**
|
|
|
|
* Initial window options
|
|
|
|
*/
|
2019-02-18 05:42:04 +00:00
|
|
|
|
2018-07-29 11:50:44 +00:00
|
|
|
mainWindow = new BrowserWindow({
|
2019-10-04 17:59:05 +00:00
|
|
|
width: 1200,
|
|
|
|
height: 907,
|
2019-10-03 13:46:12 +00:00
|
|
|
frame: false,
|
2019-10-11 09:55:50 +00:00
|
|
|
resizable: false,
|
2018-10-24 17:08:51 +00:00
|
|
|
useContentSize: true,
|
|
|
|
webPreferences: {
|
2019-07-16 06:59:35 +00:00
|
|
|
webSecurity: false,
|
|
|
|
nodeIntegration: true
|
2018-10-24 17:08:51 +00:00
|
|
|
}
|
2019-07-16 06:59:35 +00:00
|
|
|
});
|
2018-07-29 11:50:44 +00:00
|
|
|
|
2019-07-16 06:59:35 +00:00
|
|
|
mainWindow.loadURL(winURL);
|
2018-07-29 11:50:44 +00:00
|
|
|
|
|
|
|
mainWindow.on('closed', () => {
|
2019-07-16 06:59:35 +00:00
|
|
|
mainWindow = null;
|
|
|
|
});
|
2018-07-29 11:50:44 +00:00
|
|
|
|
|
|
|
setupMenu();
|
|
|
|
}
|
|
|
|
|
2019-07-16 06:59:35 +00:00
|
|
|
app.on('ready', createWindow);
|
2018-07-29 11:50:44 +00:00
|
|
|
|
|
|
|
app.on('window-all-closed', () => {
|
|
|
|
if (process.platform !== 'darwin') {
|
2019-07-16 06:59:35 +00:00
|
|
|
app.quit();
|
2018-07-29 11:50:44 +00:00
|
|
|
}
|
2019-07-16 06:59:35 +00:00
|
|
|
});
|
2018-07-29 11:50:44 +00:00
|
|
|
|
|
|
|
app.on('activate', () => {
|
|
|
|
if (mainWindow === null) {
|
2019-07-16 06:59:35 +00:00
|
|
|
createWindow();
|
2018-07-29 11:50:44 +00:00
|
|
|
}
|
2019-07-16 06:59:35 +00:00
|
|
|
});
|
2018-07-29 11:50:44 +00:00
|
|
|
|
|
|
|
// TODO:
|
|
|
|
// Enable Auto Update
|
|
|
|
// https://www.electron.build/auto-update/
|