2018-10-21 12:49:33 +00:00
|
|
|
const path = require('path');
|
2018-07-29 11:50:44 +00:00
|
|
|
const { app, BrowserWindow } = require('electron');
|
|
|
|
const { getAppConfig } = require('frappejs/webpack/utils');
|
|
|
|
const setupMenu = require('./menu');
|
|
|
|
|
|
|
|
const appConfig = getAppConfig();
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV !== 'development') {
|
2018-10-21 12:49:33 +00:00
|
|
|
global.__static = path.join(__dirname, '/static').replace(/\\/g, '\\\\')
|
2018-07-29 11:50:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let mainWindow
|
|
|
|
const winURL = process.env.NODE_ENV === 'development'
|
|
|
|
? `http://localhost:${appConfig.dev.devServerPort}`
|
|
|
|
: `file://${__dirname}/index.html`
|
|
|
|
|
|
|
|
function createWindow() {
|
|
|
|
/**
|
|
|
|
* Initial window options
|
|
|
|
*/
|
|
|
|
mainWindow = new BrowserWindow({
|
|
|
|
width: 1024,
|
|
|
|
height: 768,
|
|
|
|
useContentSize: true
|
|
|
|
})
|
|
|
|
|
|
|
|
mainWindow.loadURL(winURL)
|
|
|
|
|
|
|
|
mainWindow.on('closed', () => {
|
|
|
|
mainWindow = null
|
|
|
|
})
|
|
|
|
|
|
|
|
setupMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
app.on('ready', createWindow)
|
|
|
|
|
|
|
|
app.on('window-all-closed', () => {
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
app.quit()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
app.on('activate', () => {
|
|
|
|
if (mainWindow === null) {
|
|
|
|
createWindow()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
// Enable Auto Update
|
|
|
|
// https://www.electron.build/auto-update/
|