Create a basic ElectronJS app in src/main.js
This commit is contained in:
		@@ -2,7 +2,7 @@
 | 
			
		||||
  "name": "open-plutonium-launcher",
 | 
			
		||||
  "version": "0.0.1",
 | 
			
		||||
  "description": "A Plutonium launcher that aims to make old CoD games more accessible",
 | 
			
		||||
  "main": "main.js",
 | 
			
		||||
  "main": "src/main.js",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
	"start": "electron ."
 | 
			
		||||
  },
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										54
									
								
								src/main.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								src/main.js
									
									
									
									
									
										Normal 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();
 | 
			
		||||
});
 | 
			
		||||
		Reference in New Issue
	
	Block a user