/** * Entry point for Crimata electron app. * "Look on my Works, ye Mighty, and despair!" */ "use strict"; import { app, protocol, globalShortcut } from "electron"; import createWindow from "./window"; import main from "./main"; import { backgroundMitt } from '@/composables/useEmitter'; import { setWindowOpen, getWindowOpen } from './store'; console.log('Starting Crimata electron app.'); // Scheme must be registered before the app is ready protocol.registerSchemesAsPrivileged([ { scheme: "app", privileges: { secure: true, standard: true } } ]); const isDev = require('electron-is-dev'); // Listen for window creation. backgroundMitt.on('window-active', (state: boolean) => { setWindowOpen(state) }); /* Start main process on ready */ app.on("ready", async () => { await main(); }); app.on("will-quit", () => { globalShortcut.unregisterAll(); }); // Must keep to ensure app doesn't quit on close. app.on("before-quit", async () => { }); // Must keep to ensure app doesn't quit on close. app.on("window-all-closed", () => { }); // When user clicks app icon (re-open) app.on("activate", () => { if (!getWindowOpen()) createWindow(); }); // Exit cleanly on request from parent process in development mode. if (isDev) { process.on("SIGTERM", () => { app.quit(); }); }