2019-06-08 00:36:44 +02:00
|
|
|
import { app, BrowserWindow } from 'electron';
|
2019-07-26 23:05:29 +02:00
|
|
|
import os from 'os';
|
2019-06-18 00:36:32 +02:00
|
|
|
|
2019-06-23 03:37:43 +02:00
|
|
|
import './main/controllers/api';
|
2019-06-23 02:30:24 +02:00
|
|
|
import './main/services/database';
|
2019-07-26 23:05:29 +02:00
|
|
|
import * as session from './main/services/session';
|
|
|
|
import BrowserWindowConstructorOptions = Electron.BrowserWindowConstructorOptions;
|
2019-06-08 00:36:44 +02:00
|
|
|
|
|
|
|
let mainWindow: Electron.BrowserWindow;
|
|
|
|
|
2019-06-30 01:18:21 +02:00
|
|
|
async function createWindow(): Promise<void> {
|
2019-07-26 23:05:29 +02:00
|
|
|
session.setHeaders();
|
2019-06-09 02:47:46 +02:00
|
|
|
|
2019-07-26 23:05:29 +02:00
|
|
|
// universal options
|
|
|
|
let options: BrowserWindowConstructorOptions = {
|
2019-06-09 06:07:05 +02:00
|
|
|
width: 1600,
|
2019-06-10 10:47:26 +02:00
|
|
|
height: 900,
|
2019-06-08 00:36:44 +02:00
|
|
|
webPreferences: {
|
2019-06-16 00:41:43 +02:00
|
|
|
nodeIntegration: true,
|
2019-06-08 00:36:44 +02:00
|
|
|
},
|
2019-07-26 23:05:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// platform specifics
|
|
|
|
switch (os.platform()) {
|
|
|
|
case 'win32':
|
|
|
|
options = {
|
|
|
|
...options,
|
|
|
|
...{
|
|
|
|
icon: 'resources/icon.ico',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the browser window.
|
|
|
|
mainWindow = new BrowserWindow(options);
|
2019-06-08 00:36:44 +02:00
|
|
|
|
|
|
|
// and load the index.html of the app.
|
2019-06-16 00:41:43 +02:00
|
|
|
await mainWindow.loadFile('index.html');
|
2019-06-08 00:36:44 +02:00
|
|
|
|
|
|
|
// Open the DevTools.
|
|
|
|
mainWindow.webContents.openDevTools();
|
|
|
|
|
|
|
|
// Emitted when the window is closed.
|
|
|
|
mainWindow.on('closed', () => {
|
|
|
|
// 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;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method will be called when Electron has finished
|
|
|
|
// initialization and is ready to create browser windows.
|
|
|
|
// Some APIs can only be used after this event occurs.
|
|
|
|
app.on('ready', createWindow);
|
|
|
|
|
|
|
|
// Quit when all windows are closed.
|
|
|
|
app.on('window-all-closed', () => {
|
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-06-10 10:47:26 +02:00
|
|
|
app.on('activate', async () => {
|
2019-06-08 00:36:44 +02:00
|
|
|
// On OS X it"s common to re-create a window in the app when the
|
|
|
|
// dock icon is clicked and there are no other windows open.
|
|
|
|
if (mainWindow === null) {
|
2019-06-10 10:47:26 +02:00
|
|
|
await createWindow();
|
2019-06-08 00:36:44 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// In this file you can include the rest of your app"s specific main process
|
|
|
|
// code. You can also put them in separate files and require them here.
|