feat(agent): automatically write user configuration after app started (#516)
* auto write userconfig * fix load success action * exit from app * add electron:auto-write-config script
This commit is contained in:
committed by
László Monda
parent
e8a1814d89
commit
b32c93f0f8
@@ -3,19 +3,21 @@ import { UhkHidDevice } from 'uhk-usb';
|
||||
import { readFile } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { AppStartInfo, CommandLineArgs, IpcEvents, LogService } from 'uhk-common';
|
||||
import { AppStartInfo, IpcEvents, LogService } from 'uhk-common';
|
||||
import { MainServiceBase } from './main-service-base';
|
||||
import { DeviceService } from './device.service';
|
||||
import { CommandLineInputs } from '../models/command-line-inputs';
|
||||
|
||||
export class AppService extends MainServiceBase {
|
||||
constructor(protected logService: LogService,
|
||||
protected win: Electron.BrowserWindow,
|
||||
private deviceService: DeviceService,
|
||||
private options: CommandLineArgs,
|
||||
private options: CommandLineInputs,
|
||||
private uhkHidDeviceService: UhkHidDevice) {
|
||||
super(logService, win);
|
||||
|
||||
ipcMain.on(IpcEvents.app.getAppStartInfo, this.handleAppStartInfo.bind(this));
|
||||
ipcMain.on(IpcEvents.app.exit, this.exit.bind(this));
|
||||
logService.info('[AppService] init success');
|
||||
}
|
||||
|
||||
@@ -25,7 +27,10 @@ export class AppService extends MainServiceBase {
|
||||
const packageJson = await this.getPackageJson();
|
||||
|
||||
const response: AppStartInfo = {
|
||||
commandLineArgs: this.options,
|
||||
commandLineArgs: {
|
||||
addons: this.options.addons || false,
|
||||
autoWriteConfig: this.options['auto-write-config'] || false
|
||||
},
|
||||
deviceConnected: this.deviceService.isConnected,
|
||||
hasPermission: this.uhkHidDeviceService.hasPermission(),
|
||||
agentVersionInfo: {
|
||||
@@ -57,4 +62,9 @@ export class AppService extends MainServiceBase {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private exit() {
|
||||
this.logService.info('[AppService] exit');
|
||||
this.win.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,6 @@ export class DeviceService {
|
||||
success: true,
|
||||
...result
|
||||
};
|
||||
event.sender.send(IpcEvents.device.loadConfigurationReply, JSON.stringify(response));
|
||||
} catch (error) {
|
||||
response = {
|
||||
success: false,
|
||||
|
||||
Reference in New Issue
Block a user