52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
/**
|
|
* Entry point for Crimata electron app.
|
|
* "Look on my Works, ye Mighty, and despair!"
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
import { app, protocol } from "electron";
|
|
import createWindow from "./window";
|
|
import main from "./main";
|
|
import { backgroundMitt } from '@/composables/useEmitter';
|
|
|
|
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');
|
|
|
|
let win: boolean;
|
|
|
|
// Listen for window creation.
|
|
backgroundMitt.on('window-active', (state: boolean) => {
|
|
win = state;
|
|
});
|
|
|
|
/* Start main process on ready */
|
|
app.on("ready", async () => {
|
|
await main();
|
|
});
|
|
|
|
// 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 (!win) createWindow();
|
|
});
|
|
|
|
// Exit cleanly on request from parent process in development mode.
|
|
if (isDev) {
|
|
process.on("SIGTERM", () => {
|
|
app.quit();
|
|
});
|
|
}
|