-
-
Save abhishekY495/c28984acf3e5ea250dfa2471381d3ea4 to your computer and use it in GitHub Desktop.
Electron Main process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require("path"); | |
const { app, BrowserWindow, Menu } = require("electron"); | |
const { menuTemplate } = require("./menuTemplate.js"); | |
const isMac = process.platform === "darwin"; | |
const isDev = false; // Set to true for DevTools | |
function createMainWindow() { | |
const mainWindow = new BrowserWindow({ | |
title: "File encryptor", | |
width: 420, | |
height: 690, | |
resizable: isDev ? true : false , | |
icon: path.join(__dirname, "./icons/app-icon.ico"), | |
webPreferences: { | |
contextIsolation: true, | |
nodeIntegration: true, | |
preload: path.join(__dirname, "./preload.js"), | |
}, | |
}); | |
if (isDev) { | |
mainWindow.webContents.openDevTools(); | |
} | |
mainWindow.loadFile(path.join(__dirname, "../src/index.html")); | |
} | |
app.whenReady().then(() => { | |
createMainWindow(); | |
const menu = Menu.buildFromTemplate(menuTemplate); | |
Menu.setApplicationMenu(menu); | |
app.on("activate", () => { | |
if (BrowserWindow.getAllWindows().length === 0) { | |
createMainWindow(); | |
} | |
}); | |
}); | |
app.on("window-all-closed", () => { | |
if (!isMac) { | |
app.quit(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment