2
0
mirror of https://github.com/frappe/books.git synced 2024-11-09 23:30:56 +00:00
books/main/registerAppLifecycleListeners.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
974 B
TypeScript
Raw Normal View History

import { app } from 'electron';
import installExtension, { VUEJS3_DEVTOOLS } from 'electron-devtools-installer';
import { Main } from '../main';
2022-05-27 08:30:25 +00:00
import { rendererLog } from './helpers';
import { emitMainProcessError } from 'backend/helpers';
export default function registerAppLifecycleListeners(main: Main) {
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (main.mainWindow === null) {
main.createWindow().catch((err) => emitMainProcessError(err));
}
});
app.on('ready', () => {
2022-05-27 08:30:25 +00:00
if (main.isDevelopment && !main.isTest) {
installDevTools(main).catch((err) => emitMainProcessError(err));
}
main.createWindow().catch((err) => emitMainProcessError(err));
});
}
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);
}
}