55 lines
1.8 KiB
TypeScript
Executable file
55 lines
1.8 KiB
TypeScript
Executable file
import path from "node:path";
|
|
import { app, ipcMain } from "electron";
|
|
import log from "electron-log/main";
|
|
import UnzipData from "./UnzipData";
|
|
import BrowserWinHandler from "./browserWinHandler";
|
|
|
|
// TODO: take inspiration form https://github.com/michalzaq12/electron-nuxt/tree/master/template/src/main.
|
|
// Or https://github.com/EternalC0der/electron-nuxt3
|
|
|
|
log.initialize();
|
|
|
|
// Quit when all windows are closed.
|
|
app.on("window-all-closed", function () {
|
|
// On macOS it is common for applications and their menu bar
|
|
// to stay active until the user quits explicitly with Cmd + Q
|
|
if (process.platform !== "darwin") app.quit();
|
|
});
|
|
|
|
app.whenReady().then(() => {
|
|
// * Run an Electron window ?
|
|
if (process.env.npm_lifecycle_event === "electron") {
|
|
const winHandler = new BrowserWinHandler({
|
|
kiosk: false,
|
|
closable: true,
|
|
alwaysOnTop: false,
|
|
fullscreen: false,
|
|
autoHideMenuBar: false,
|
|
webPreferences: {
|
|
preload: path.join(__dirname, "versions.js")
|
|
}
|
|
});
|
|
|
|
winHandler.onCreated(_browserWindow => {
|
|
try {
|
|
const appData = UnzipData.loadZipFileContent();
|
|
if (!appData) {
|
|
throw new Error("No zip file to load");
|
|
}
|
|
// this is the event listener that will respond when we will request it in the web page
|
|
ipcMain.on("get-config", (event) => {
|
|
log.info("read json app config");
|
|
event.returnValue = appData;
|
|
});
|
|
|
|
winHandler.loadPage("ranges");
|
|
winHandler.openDevTool();
|
|
} catch (err) {
|
|
log.error(err);
|
|
winHandler.quit();
|
|
}
|
|
});
|
|
|
|
// fs.readFile();
|
|
}
|
|
});
|