Initial commit
This commit is contained in:
@@ -1,26 +1,30 @@
|
||||
import { Door } from 'shared-lib';
|
||||
import * as remoteMain from '@electron/remote/main';
|
||||
import { app, BrowserWindow, ipcMain, nativeImage } from 'electron';
|
||||
import * as path from 'node:path';
|
||||
import { AbstractService } from '../services/abstract-service';
|
||||
import { MultiplesService } from '../services/multiples-service';
|
||||
import { FileListService } from '../services/file-list-service';
|
||||
import { PrintService } from './../services/print-service';
|
||||
import { Logger } from '../utils/logger';
|
||||
import { DoorService } from '../services/door-service';
|
||||
|
||||
declare const global: Global;
|
||||
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string;
|
||||
|
||||
export class Window {
|
||||
private _electronWindow: BrowserWindow | undefined;
|
||||
private _printService: PrintService;
|
||||
|
||||
constructor() {
|
||||
this.createWindow();
|
||||
this.loadRenderer();
|
||||
this.registerService<number, number[]>(new MultiplesService());
|
||||
this.registerService<void, any[]>(new FileListService());
|
||||
this.registerService<string, Door[]>(new DoorService());
|
||||
}
|
||||
|
||||
private createWindow(): void {
|
||||
this._electronWindow = new BrowserWindow({
|
||||
width: 1280,
|
||||
height: 720,
|
||||
fullscreen: false,
|
||||
backgroundColor: '#FFFFFF',
|
||||
icon: this.loadIcon(),
|
||||
webPreferences: {
|
||||
@@ -41,6 +45,10 @@ export class Window {
|
||||
},
|
||||
});
|
||||
|
||||
this._printService = new PrintService();
|
||||
this._printService.setWindow(this._electronWindow);
|
||||
this.registerService<string, void>(this._printService);
|
||||
|
||||
// Disable the remote module to enhance security
|
||||
// except in e2e test when that access is required
|
||||
if (global.appConfig.isEnableRemoteModule) {
|
||||
@@ -105,16 +113,16 @@ export class Window {
|
||||
// Handling input
|
||||
const input = parameters[0];
|
||||
Logger.debug(`[${service.receptionChannel()}] =====> `, input);
|
||||
const output: Out = service.process(input);
|
||||
|
||||
// Handling output
|
||||
if (service.sendingChannel()) {
|
||||
Logger.debug(`[${service.sendingChannel()}] =====> `, output);
|
||||
this._electronWindow.webContents.send(
|
||||
service.sendingChannel(),
|
||||
output
|
||||
);
|
||||
}
|
||||
service.process(input).then((output: Out) => {
|
||||
// Handling output
|
||||
if (service.sendingChannel()) {
|
||||
Logger.debug(`[${service.sendingChannel()}] =====> `, output);
|
||||
this._electronWindow.webContents.send(
|
||||
service.sendingChannel(),
|
||||
output
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user