/
index.js
31 lines (25 loc) · 875 Bytes
/
index.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
const { join } = require("path");
const { BrowserWindow, app, ipcMain } = require("electron");
const serveNext = require("next-electron-server");
// Register your own scheme and host
serveNext("next://app");
app.whenReady().then(async () => {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: false,
preload: join(__dirname, "preload.js"),
},
});
// Load renderer using a custom protocol:
mainWindow.loadURL("next://app");
// You can load deeplinks too (e.g: pages/about):
// mainWindow.loadURL("next://app/about");
});
// Quit the app once all windows are closed
app.on("window-all-closed", app.quit);
// listen the channel `message` and resend the received message to the renderer process
ipcMain.on("message", (event, message) => {
event.sender.send("message", message);
});