-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
59 lines (52 loc) · 1.68 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const { app, BrowserWindow, ipcMain } = require("electronite");
const path = require("path");
const isDev = !app.isPackaged;
require("@electron/remote/main").initialize();
// Browser Window <- Renderer Process
function createWindow() {
// Browser Window <- Renderer Process
const win = new BrowserWindow({
width: 1200,
height: 1000,
//minWidth:800,
//minHeight:700,
// backgroundColor: "white",
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
// will sanitize JS code
// TODO: explain when React application is initialize
worldSafeExecuteJavaScript: true,
// is a feature that ensures that both, your preload scripts and Electron
// internal logic run in separate context
contextIsolation: false,
},
});
require("@electron/remote/main").enable(win.webContents);
win.loadFile("index.html");
win.setMenu(null);
// isDev && win.webContents.openDevTools();
}
if (isDev) {
require("electron-reload")(__dirname, {
electron: path.join(__dirname, "node_modules", ".bin", "electronite"),
});
}
app.whenReady().then(createWindow);
app.on("window-all-closed", () => {
if (process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
// Chromium -> web eingine for rendering the UI, full Chrome-like web browser
// V8 -> engine that provides capabilities to execute, run, JS code in the browser
// Node JS(V8) -> we are able to run JS code + provides more features
// ipcMain.on('print', (event, options) => {
// const win = BrowserWindow.getFocusedWindow();
// win.webContents.print(options);
// });