2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00
books/main/registerAppLifecycleListeners.ts
2022-05-23 16:18:23 +05:30

33 lines
757 B
TypeScript

import { app } from 'electron';
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();
});
}