* Add generate version module script
* Remove Fork me on GitHub banner
* Add app-version.ts
* Revert "Add app-version.ts"
This reverts commit fe1a37e631.
* Add app-version.ts
* Add agent icon class
* Move settings component under agent folder
* Add AboutComponent
* Add agent routes
* Add index.ts for agent folder
* Fix agent folder imports in shared module
* Add agent menu to side menu, with Settings and About pages under it
* Fix agent icon alignment in side menu
* Simplify About page
* Make Agent menu 0 level in side menu
* Remove bottom Settings menu
* Fix Agent menu closing if My UHK is closed in side menu
* Fix version text alignment in auto update settings
* Remove github fork ribbon styles
* use package.json instead of app-version.ts
* fix OpenUrlInNewWindow naming
* fix lint request
* fix: firmware download url calculation
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
import { Injectable, NgZone } from '@angular/core';
|
|
import { Action, Store } from '@ngrx/store';
|
|
|
|
import { AppStartInfo, IpcEvents, LogService } from 'uhk-common';
|
|
import { AppState } from '../store';
|
|
import { ElectronMainLogReceivedAction, ProcessAppStartInfoAction } from '../store/actions/app';
|
|
import { IpcCommonRenderer } from './ipc-common-renderer';
|
|
|
|
@Injectable()
|
|
export class AppRendererService {
|
|
constructor(private store: Store<AppState>,
|
|
private zone: NgZone,
|
|
private ipcRenderer: IpcCommonRenderer,
|
|
private logService: LogService) {
|
|
this.registerEvents();
|
|
this.logService.info('[AppRendererService] init success ');
|
|
}
|
|
|
|
getAppStartInfo() {
|
|
this.logService.info('[AppRendererService] getAppStartInfo');
|
|
this.ipcRenderer.send(IpcEvents.app.getAppStartInfo);
|
|
}
|
|
|
|
exit() {
|
|
this.logService.info('[AppRendererService] exit');
|
|
this.ipcRenderer.send(IpcEvents.app.exit);
|
|
}
|
|
|
|
openUrl(url: string): void {
|
|
this.logService.info(`[AppRendererService] open url: ${url}`);
|
|
this.ipcRenderer.send(IpcEvents.app.openUrl, url);
|
|
}
|
|
|
|
private registerEvents() {
|
|
this.ipcRenderer.on(IpcEvents.app.getAppStartInfoReply, (event: string, arg: AppStartInfo) => {
|
|
this.dispachStoreAction(new ProcessAppStartInfoAction(arg));
|
|
});
|
|
|
|
this.ipcRenderer.on('__ELECTRON_LOG_RENDERER__', (event: string, level: string, message: string) => {
|
|
this.zone.run(() => this.store.dispatch(new ElectronMainLogReceivedAction({level, message})));
|
|
});
|
|
}
|
|
|
|
private dispachStoreAction(action: Action) {
|
|
this.logService.info('[AppRendererService] dispatch action', action);
|
|
this.zone.run(() => this.store.dispatch(action));
|
|
}
|
|
}
|