2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 03:29:00 +00:00
books/main/registerAppLifecycleListeners.ts

34 lines
771 B
TypeScript

import { app } from 'electron';
// @ts-ignore
import installExtension, { VUEJS3_DEVTOOLS } from 'electron-devtools-installer';
import { Main } from '../main';
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();
}
});
app.on('ready', async () => {
if (main.isDevelopment && !process.env.IS_TEST) {
try {
await installExtension(VUEJS3_DEVTOOLS);
} catch (e) {
console.error(
'Vue Devtools failed to install:',
(e as Error).toString()
);
}
}
main.createWindow();
});
}