Added application settings and basic filewatcher.
This commit is contained in:
@@ -1,34 +1,39 @@
|
||||
const path = require("path");
|
||||
require("./ipc-handler");
|
||||
const { app, BrowserWindow } = require("electron");
|
||||
const isDev = require("electron-is-dev");
|
||||
const settings = require("electron-settings");
|
||||
|
||||
require("./ipc-handler");
|
||||
|
||||
// Conditionally include the dev tools installer to load React Dev Tools
|
||||
let installExtension, REACT_DEVELOPER_TOOLS; // NEW!
|
||||
let installExtension, REACT_DEVELOPER_TOOLS;
|
||||
if (isDev) {
|
||||
const devTools = require("electron-devtools-installer");
|
||||
installExtension = devTools.default;
|
||||
REACT_DEVELOPER_TOOLS = devTools.REACT_DEVELOPER_TOOLS;
|
||||
} // NEW!
|
||||
}
|
||||
|
||||
// Handle creating/removing shortcuts on Windows when installing/uninstalling
|
||||
if (require("electron-squirrel-startup")) {
|
||||
app.quit();
|
||||
} // NEW!
|
||||
}
|
||||
|
||||
var mainWindow = null;
|
||||
function createWindow() {
|
||||
// Create the browser window.
|
||||
const win = new BrowserWindow({
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 800,
|
||||
height: 600,
|
||||
title: "ImEX RPS",
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
enableRemoteModule: true,
|
||||
},
|
||||
});
|
||||
|
||||
// and load the index.html of the app.
|
||||
// win.loadFile("index.html");
|
||||
win.loadURL(
|
||||
mainWindow.loadURL(
|
||||
isDev
|
||||
? "http://localhost:3000"
|
||||
: `file://${path.join(__dirname, "../build/index.html")}`
|
||||
@@ -36,10 +41,10 @@ function createWindow() {
|
||||
|
||||
// Open the DevTools.
|
||||
if (isDev) {
|
||||
win.webContents.openDevTools({ mode: "detach" });
|
||||
mainWindow.webContents.openDevTools({ mode: "detach" });
|
||||
}
|
||||
}
|
||||
|
||||
exports.mainWindow = mainWindow;
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
@@ -48,10 +53,13 @@ app.whenReady().then(() => {
|
||||
createWindow();
|
||||
|
||||
if (isDev) {
|
||||
console.log(`Path to Settings File: ${settings.file()}`);
|
||||
installExtension(REACT_DEVELOPER_TOOLS)
|
||||
.then((name) => console.log(`Added Extension: ${name}`))
|
||||
.catch((error) => console.log(`An error occurred: , ${error}`));
|
||||
}
|
||||
|
||||
//Start all of the watchers.
|
||||
});
|
||||
|
||||
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
|
||||
Reference in New Issue
Block a user