2023-09-11 04:25:14 +02:00
|
|
|
import { BrowserWindow, shell } from "electron";
|
2023-09-10 20:00:49 +02:00
|
|
|
import { getPlatform } from "./utils/get-device-specs";
|
2023-09-10 11:14:04 +02:00
|
|
|
import { join } from "path";
|
2023-09-11 04:25:14 +02:00
|
|
|
import COMMAND from "./constants/commands";
|
|
|
|
import {
|
|
|
|
overwrite,
|
|
|
|
setCustomModelsFolderPath,
|
|
|
|
setFolderPath,
|
|
|
|
setImagePath,
|
|
|
|
setOutputFolderPath,
|
|
|
|
setOverwrite,
|
2023-09-13 16:07:45 +02:00
|
|
|
setCompression,
|
2023-09-11 04:25:14 +02:00
|
|
|
setSaveOutputFolder,
|
2023-09-18 20:30:43 +02:00
|
|
|
fetchLocalStorage,
|
2023-09-11 04:25:14 +02:00
|
|
|
} from "./utils/config-variables";
|
|
|
|
import electronIsDev from "electron-is-dev";
|
2023-09-13 15:14:46 +02:00
|
|
|
import { format } from "url";
|
2023-09-10 11:14:04 +02:00
|
|
|
|
2023-09-13 15:14:46 +02:00
|
|
|
let mainWindow: BrowserWindow | undefined;
|
2023-09-10 11:14:04 +02:00
|
|
|
|
2023-09-10 19:42:18 +02:00
|
|
|
const createMainWindow = () => {
|
|
|
|
mainWindow = new BrowserWindow({
|
|
|
|
icon: join(__dirname, "build", "icon.png"),
|
|
|
|
width: 1300,
|
|
|
|
height: 940,
|
|
|
|
minHeight: 500,
|
|
|
|
minWidth: 500,
|
|
|
|
show: false,
|
|
|
|
backgroundColor: "#171717",
|
|
|
|
webPreferences: {
|
|
|
|
nodeIntegration: true,
|
|
|
|
nodeIntegrationInWorker: true,
|
|
|
|
webSecurity: false,
|
|
|
|
preload: join(__dirname, "preload.js"),
|
|
|
|
},
|
|
|
|
titleBarStyle: getPlatform() === "mac" ? "hiddenInset" : "default",
|
|
|
|
});
|
2023-09-10 11:14:04 +02:00
|
|
|
|
2023-09-11 04:25:14 +02:00
|
|
|
const url = electronIsDev
|
|
|
|
? "http://localhost:8000"
|
2023-09-13 15:14:46 +02:00
|
|
|
: format({
|
|
|
|
pathname: join(__dirname, "../renderer/out/index.html"),
|
|
|
|
protocol: "file:",
|
|
|
|
slashes: true,
|
|
|
|
});
|
|
|
|
|
2023-09-11 04:25:14 +02:00
|
|
|
mainWindow.loadURL(url);
|
|
|
|
|
|
|
|
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
|
|
|
|
shell.openExternal(url);
|
|
|
|
return { action: "deny" };
|
|
|
|
});
|
|
|
|
|
|
|
|
mainWindow.once("ready-to-show", () => {
|
|
|
|
if (!mainWindow) return;
|
|
|
|
mainWindow.show();
|
|
|
|
});
|
|
|
|
|
2023-09-18 20:30:43 +02:00
|
|
|
fetchLocalStorage();
|
2023-09-11 04:25:14 +02:00
|
|
|
|
|
|
|
mainWindow.webContents.send(COMMAND.OS, getPlatform());
|
|
|
|
|
2023-09-10 19:42:18 +02:00
|
|
|
mainWindow.setMenuBarVisibility(false);
|
|
|
|
};
|
|
|
|
|
|
|
|
const getMainWindow = () => {
|
|
|
|
return mainWindow;
|
|
|
|
};
|
2023-09-10 11:14:04 +02:00
|
|
|
|
2023-09-10 19:42:18 +02:00
|
|
|
export { createMainWindow, getMainWindow };
|