RenaiApp/src/main.ts

51 lines
1.8 KiB
TypeScript

/* eslint-disable import/order -- this is the entry point for the application and some things have to happen before others */
import { container } from './main/core/container';
import './main/core/install';
import { app } from 'electron';
import { isDev } from './main/core/dev';
import { IAppWindow } from './main/modules/app-window/i-app-window';
import { ISession } from './main/modules/session/i-session';
async function createWindow(): Promise<void> {
const session: ISession = container.get(Symbol.for('session'));
session.setHeaders();
const appWindowMain: IAppWindow = container.get(Symbol.for('app-window-main'));
// and load the index.html of the app.
await appWindowMain.open();
// Open the DevTools.
if (isDev()) {
// eslint-disable-next-line no-unused-expressions -- eslint can't handle optional chaining, yet
appWindowMain.window?.webContents.openDevTools();
}
}
// 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();
}
});
app.on('activate', async () => {
// 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.
const appWindowMain: IAppWindow = container.get(Symbol.for('app-window-main'));
if (appWindowMain.isClosed()) {
await createWindow();
}
});
// 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.