mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
electron main class
This commit is contained in:
77
src/main.ts
77
src/main.ts
@@ -1,42 +1,59 @@
|
||||
import { BrowserWindow } from 'electron';
|
||||
|
||||
import { DesktopMainMessagingService } from './services/desktopMainMessaging.service';
|
||||
import { DesktopStorageService } from './services/desktopStorage.service';
|
||||
import { I18nService } from './services/i18n.service';
|
||||
|
||||
import { MenuMain } from './main/menu.main';
|
||||
import { MessagingMain } from './main/messaging.main';
|
||||
import { PowerMonitorMain } from './main/powerMonitor.main';
|
||||
import { UpdaterMain } from './main/updater.main';
|
||||
import { WindowMain } from './main/window.main';
|
||||
|
||||
import { DesktopMainMessagingService } from './services/desktopMainMessaging.service';
|
||||
import { DesktopStorageService } from './services/desktopStorage.service';
|
||||
import { I18nService } from './services/i18n.service';
|
||||
export class Main {
|
||||
i18nService: I18nService;
|
||||
storageService: DesktopStorageService;
|
||||
messagingService: DesktopMainMessagingService;
|
||||
|
||||
const args = process.argv.slice(1);
|
||||
const watch = args.some((val) => val === '--watch');
|
||||
const dev = args.some((val) => val === '--dev');
|
||||
windowMain: WindowMain;
|
||||
messagingMain: MessagingMain;
|
||||
updaterMain: UpdaterMain;
|
||||
menuMain: MenuMain;
|
||||
powerMonitorMain: PowerMonitorMain;
|
||||
|
||||
if (watch) {
|
||||
// tslint:disable-next-line
|
||||
require('electron-reload')(__dirname, {});
|
||||
constructor() {
|
||||
const args = process.argv.slice(1);
|
||||
const watch = args.some((val) => val === '--watch');
|
||||
|
||||
if (watch) {
|
||||
// tslint:disable-next-line
|
||||
require('electron-reload')(__dirname, {});
|
||||
}
|
||||
|
||||
this.i18nService = new I18nService('en', './locales/');
|
||||
this.storageService = new DesktopStorageService();
|
||||
this.messagingService = new DesktopMainMessagingService(this);
|
||||
|
||||
this.windowMain = new WindowMain(this);
|
||||
this.messagingMain = new MessagingMain(this);
|
||||
this.updaterMain = new UpdaterMain(this);
|
||||
this.menuMain = new MenuMain(this);
|
||||
this.powerMonitorMain = new PowerMonitorMain(this);
|
||||
}
|
||||
|
||||
bootstrap() {
|
||||
this.windowMain.init().then(async () => {
|
||||
await this.i18nService.init();
|
||||
this.messagingMain.init();
|
||||
this.menuMain.init();
|
||||
this.powerMonitorMain.init();
|
||||
await this.updaterMain.init();
|
||||
}, (e: any) => {
|
||||
// tslint:disable-next-line
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const windowMain = new WindowMain(dev);
|
||||
const messagingMain = new MessagingMain(windowMain);
|
||||
|
||||
const i18nService = new I18nService('en', './locales/');
|
||||
const storageService = new DesktopStorageService();
|
||||
const messagingService = new DesktopMainMessagingService(windowMain, messagingMain);
|
||||
|
||||
const updaterMain = new UpdaterMain(windowMain, i18nService);
|
||||
const menuMain = new MenuMain(windowMain, updaterMain, i18nService, messagingService);
|
||||
const powerMonitorMain = new PowerMonitorMain(storageService, messagingService);
|
||||
|
||||
windowMain.init().then(async () => {
|
||||
messagingMain.init();
|
||||
await i18nService.init();
|
||||
menuMain.init();
|
||||
powerMonitorMain.init();
|
||||
await updaterMain.init();
|
||||
}, (e: any) => {
|
||||
// tslint:disable-next-line
|
||||
console.log(e);
|
||||
});
|
||||
const main = new Main();
|
||||
main.bootstrap();
|
||||
|
||||
Reference in New Issue
Block a user