2020-02-09 20:25:05 +01:00
|
|
|
/* eslint-disable import/order */
|
|
|
|
/**
|
|
|
|
* Disable Reasons
|
|
|
|
*
|
|
|
|
* import/order: this is the entry point for the application and some things have to happen before others
|
|
|
|
*/
|
2020-02-08 23:26:57 +01:00
|
|
|
import { container } from './main/core/container';
|
2020-02-09 20:25:05 +01:00
|
|
|
import './main/core/install';
|
|
|
|
|
|
|
|
import { app } from 'electron';
|
2020-02-08 23:26:57 +01:00
|
|
|
import { isDev } from './main/core/dev';
|
|
|
|
import { IAppWindow } from './main/modules/app-window/i-app-window';
|
|
|
|
import { ISession } from './main/modules/session/i-session';
|
2019-12-10 23:33:48 +01:00
|
|
|
|
2019-06-30 01:18:21 +02:00
|
|
|
async function createWindow(): Promise<void> {
|
2020-02-08 23:26:57 +01:00
|
|
|
const session: ISession = container.get(Symbol.for('session'));
|
2019-07-26 23:05:29 +02:00
|
|
|
session.setHeaders();
|
2019-06-09 02:47:46 +02:00
|
|
|
|
2020-02-08 23:26:57 +01:00
|
|
|
const appWindowMain: IAppWindow = container.get(Symbol.for('app-window-main'));
|
2019-06-08 00:36:44 +02:00
|
|
|
|
|
|
|
// and load the index.html of the app.
|
2020-02-08 23:26:57 +01:00
|
|
|
await appWindowMain.open();
|
2019-06-08 00:36:44 +02:00
|
|
|
|
|
|
|
// Open the DevTools.
|
2019-12-11 14:24:00 +01:00
|
|
|
if (isDev()) {
|
2020-02-08 23:26:57 +01:00
|
|
|
appWindowMain.window.webContents.openDevTools();
|
2019-12-11 14:24:00 +01:00
|
|
|
}
|
2019-06-08 00:36:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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.
|
2020-02-08 23:26:57 +01:00
|
|
|
const appWindowMain: IAppWindow = container.get(Symbol.for('app-window-main'));
|
|
|
|
if (appWindowMain.isClosed()) {
|
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.
|