Create a basic ElectronJS app in src/main.js

This commit is contained in:
X3F200C 2024-11-08 22:58:23 -05:00
parent 4bf86f258e
commit 03e7a5735a
2 changed files with 55 additions and 1 deletions

View File

@ -2,7 +2,7 @@
"name": "open-plutonium-launcher", "name": "open-plutonium-launcher",
"version": "0.0.1", "version": "0.0.1",
"description": "A Plutonium launcher that aims to make old CoD games more accessible", "description": "A Plutonium launcher that aims to make old CoD games more accessible",
"main": "main.js", "main": "src/main.js",
"scripts": { "scripts": {
"start": "electron ." "start": "electron ."
}, },

54
src/main.js Normal file
View File

@ -0,0 +1,54 @@
const path = require("node:path");
const fs = require("node:fs");
const https = require("node:https");
const process = require("node:process");
const os = require("node:os");
const child_process = require("node:child_process");
const electron = require("electron");
let configFilePath;
switch (os.platform()) {
case "win32":
configFilePath = path.join(process.env["LOCALAPPDATA"], "Plutonium", "open-plutonium-launcher.json");
break;
case "linux":
configFilePath = path.join(os.userInfo().homedir, ".config", "open-plutonium-launcher.json");
break;
case "darwin":
configFilePath = path.join(os.userInfo().homedir, "Library", "Application Support", "open-plutonium-launcher.json");
break;
default:
electron.dialog.showErrorBox("Incompatible system", "Sorry, your operating system doesn't seem to be supported...");
process.exit(1);
}
let mainWindow;
function createMainWindow() {
mainWindow = new electron.BrowserWindow({
"minWidth": 640,
"minHeight": 480,
"width": 800,
"height": 600,
"fullscreenable": false,
"show": false,
"webPreferences": {
"preload": path.join(__dirname, "preload.js"),
"contextIsolation": true
}
});
mainWindow.loadFile(path.join(__dirname, "index.html"));
mainWindow.once("ready-to-show", function () {
mainWindow.show();
});
}
electron.app.once("ready", function () {
createMainWindow();
});
electron.app.on("window-all-closed", function () {
electron.app.quit();
});