1
0
mirror of https://github.com/upscayl/upscayl.git synced 2025-02-17 19:19:23 +01:00
upscayl/main/index.js
2022-08-15 12:36:31 +05:30

45 lines
1.1 KiB
JavaScript

// Native
const { join } = require("path");
const { format } = require("url");
const { exec } = require("child_process");
const fs = require("fs");
// Packages
const { BrowserWindow, app, ipcMain } = require("electron");
const isDev = require("electron-is-dev");
const prepareNext = require("electron-next");
// Prepare the renderer once the app is ready
app.on("ready", async () => {
await prepareNext("./renderer");
const mainWindow = new BrowserWindow({
width: 1100,
height: 700,
webPreferences: {
autoHideMenuBar: true,
nodeIntegration: false,
preload: join(__dirname, "preload.js"),
},
});
const url = isDev
? "http://localhost:8000"
: format({
pathname: join(__dirname, "../renderer/out/index.html"),
protocol: "file:",
slashes: true,
});
mainWindow.setMenuBarVisibility(false);
mainWindow.maximize();
mainWindow.loadURL(url);
});
// Quit the app once all windows are closed
app.on("window-all-closed", app.quit);
// listen the channel `message` and resend the received message to the renderer process
ipcMain.on("sendMessage", (_, message) => {
console.log(message);
});