2022-03-16 09:49:48 +00:00
|
|
|
import { app } from 'electron';
|
2022-03-17 04:32:40 +00:00
|
|
|
import installExtension, { VUEJS3_DEVTOOLS } from 'electron-devtools-installer';
|
2022-03-16 09:49:48 +00:00
|
|
|
import { Main } from '../main';
|
2022-05-27 08:30:25 +00:00
|
|
|
import { rendererLog } from './helpers';
|
2023-06-22 06:34:32 +00:00
|
|
|
import { emitMainProcessError } from 'backend/helpers';
|
2022-03-16 09:49:48 +00:00
|
|
|
|
|
|
|
export default function registerAppLifecycleListeners(main: Main) {
|
|
|
|
app.on('window-all-closed', () => {
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
app.quit();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
app.on('activate', () => {
|
|
|
|
if (main.mainWindow === null) {
|
2023-06-22 06:34:32 +00:00
|
|
|
main.createWindow().catch((err) => emitMainProcessError(err));
|
2022-03-16 09:49:48 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-06-22 06:34:32 +00:00
|
|
|
app.on('ready', () => {
|
2022-05-27 08:30:25 +00:00
|
|
|
if (main.isDevelopment && !main.isTest) {
|
2023-06-22 06:34:32 +00:00
|
|
|
installDevTools(main).catch((err) => emitMainProcessError(err));
|
2022-03-16 09:49:48 +00:00
|
|
|
}
|
|
|
|
|
2023-06-22 06:34:32 +00:00
|
|
|
main.createWindow().catch((err) => emitMainProcessError(err));
|
2022-03-16 09:49:48 +00:00
|
|
|
});
|
|
|
|
}
|
2022-05-27 08:30:25 +00:00
|
|
|
|
|
|
|
async function installDevTools(main: Main) {
|
|
|
|
try {
|
|
|
|
await installExtension(VUEJS3_DEVTOOLS);
|
|
|
|
} catch (e) {
|
|
|
|
rendererLog(main, 'Vue Devtools failed to install', e);
|
|
|
|
}
|
|
|
|
}
|