50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import { app, BrowserWindow } from 'electron'
|
|
import { CONFIG_KEYS } from '@common/constants'
|
|
import { setupMainWindow } from './wins';
|
|
import started from 'electron-squirrel-startup'
|
|
import configManager from '@main/service/config-service'
|
|
import { runTaskOperationService } from '@main/process/runTaskOperationService'
|
|
import log from 'electron-log';
|
|
// import logManager from '@main/service/logger'
|
|
|
|
|
|
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
|
if (started) {
|
|
app.quit();
|
|
}
|
|
|
|
// process.on('uncaughtException', (err) => {
|
|
// logManager.error('uncaughtException', err);
|
|
// });
|
|
|
|
// process.on('unhandledRejection', (reason, promise) => {
|
|
// logManager.error('unhandledRejection', reason, promise);
|
|
// });
|
|
|
|
app.whenReady().then(() => {
|
|
setupMainWindow();
|
|
|
|
// 开启任务操作子进程
|
|
runTaskOperationService()
|
|
|
|
// 开启subagent子进程
|
|
});
|
|
|
|
// Quit when all windows are closed, except on macOS. There, it's common
|
|
// for applications and their menu bar to stay active until the user quits
|
|
// explicitly with Cmd + Q.
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin' && !configManager.get(CONFIG_KEYS.MINIMIZE_TO_TRAY)) {
|
|
log.info('app closing due to all windows being closed');
|
|
app.quit();
|
|
}
|
|
});
|
|
|
|
// On OS X it's common to re-create a window in the app when the
|
|
// dock icon is clicked and there are no other windows open.
|
|
app.on('activate', () => {
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
setupMainWindow();
|
|
}
|
|
});
|