You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
47 lines
1.3 KiB
const path = require("path");
|
|
const { app, shell, BrowserWindow, ipcMain } = require("electron");
|
|
const { createBackend } = require("./backend");
|
|
|
|
let win;
|
|
function createWindow() {
|
|
// Create the browser window.
|
|
win = new BrowserWindow({
|
|
width: 600,
|
|
height: 800,
|
|
minHeight: 800,
|
|
minWidth: 600,
|
|
title: "XNV",
|
|
autoHideMenuBar: true,
|
|
webPreferences: {
|
|
nodeIntegration: false,
|
|
contextIsolation: true,
|
|
enableRemoteModule: false,
|
|
preload: path.join(__dirname, "preload.js")
|
|
}
|
|
});
|
|
|
|
const backend = createBackend({
|
|
directory: "./.bin"
|
|
// directory: "C:/Users/AdamM/Documents/notes"
|
|
});
|
|
|
|
ipcMain.on("note_command", async (event, args) => {
|
|
const response = await backend.onNoteCommand(JSON.parse(args));
|
|
win.webContents.send("note_response", JSON.stringify(response));
|
|
});
|
|
|
|
ipcMain.on("element-clicked", async (event, args) => {
|
|
console.log("opening browser window to ", args);
|
|
shell.openExternal(args);
|
|
});
|
|
|
|
if (process.env.NODE_ENV !== "prod") {
|
|
win.loadURL("http://localhost:3000");
|
|
} else {
|
|
// and load the index.html of the app.
|
|
win.loadFile("./build/index.html");
|
|
}
|
|
}
|
|
|
|
app.on("ready", createWindow);
|