mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-07 08:06:49 +08:00
Feat: Supplemented restart events
This commit is contained in:
parent
f1dcb8ffe6
commit
31ad1e1c1b
@ -4,6 +4,8 @@ export const ALAS_CONFIG_TEST_TEMPLATE_YAML = 'deploy.test.template.yaml';
|
||||
export const ALAS_INSTR_FILE = 'installer.py';
|
||||
export const ALAS_RELAUNCH_ARGV = '--relaunch';
|
||||
|
||||
export const UPDATE_APP = 'Update app.asar';
|
||||
|
||||
export const RepositoryMap = {
|
||||
china: 'cn',
|
||||
global: 'global',
|
||||
|
@ -1,7 +1,8 @@
|
||||
import configInfo from '@/config';
|
||||
import {PyShell} from '@/pyshell';
|
||||
import {ServiceModule, event} from '@/services/index';
|
||||
import {ALAS_RELAUNCH_ARGV, BrowserWindowsIdentifier} from '@alas/common';
|
||||
import {ALAS_RELAUNCH_ARGV, UPDATE_APP, BrowserWindowsIdentifier} from '@alas/common';
|
||||
import relaunchApp from '@/utils/relaunchApp';
|
||||
|
||||
const {installerArgs, installerPath} = configInfo;
|
||||
|
||||
@ -26,6 +27,10 @@ export default class ScriptService extends ServiceModule {
|
||||
// 把服务挂在到app上
|
||||
this.app.initScriptService(alas);
|
||||
|
||||
const restApp = (message: string) => {
|
||||
message?.includes(UPDATE_APP) && relaunchApp();
|
||||
};
|
||||
|
||||
/**
|
||||
* 监听相关的事件
|
||||
*/
|
||||
@ -40,13 +45,16 @@ export default class ScriptService extends ServiceModule {
|
||||
dispatchEvent('scriptLog', err.message);
|
||||
});
|
||||
alas?.on('stdout', function (message) {
|
||||
restApp(message);
|
||||
dispatchEvent('scriptLog', message);
|
||||
});
|
||||
|
||||
alas?.on('message', function (message) {
|
||||
restApp(message);
|
||||
dispatchEvent('scriptLog', message);
|
||||
});
|
||||
alas?.on('stderr', function (message: string) {
|
||||
restApp(message);
|
||||
dispatchEvent('scriptLog', message);
|
||||
/**
|
||||
* Receive logs, judge if Alas is ready
|
||||
|
15
webapp/packages/main/src/utils/relaunchApp.ts
Normal file
15
webapp/packages/main/src/utils/relaunchApp.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import {app} from 'electron';
|
||||
import {ALAS_RELAUNCH_ARGV} from '@alas/common';
|
||||
|
||||
export const isRelaunch = process.argv.includes(ALAS_RELAUNCH_ARGV);
|
||||
|
||||
function relaunchApp() {
|
||||
/**
|
||||
* TODO Some events need to be rehandled for restart operations
|
||||
*/
|
||||
if (!isRelaunch) {
|
||||
app.relaunch({args: process.argv.slice(1).concat([ALAS_RELAUNCH_ARGV])});
|
||||
}
|
||||
}
|
||||
|
||||
export default relaunchApp;
|
Loading…
Reference in New Issue
Block a user