-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
55 lines (47 loc) · 1.55 KB
/
main.js
File metadata and controls
55 lines (47 loc) · 1.55 KB
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
import { app, BrowserWindow } from 'electron';
import isDev from 'electron-is-dev';
import path from "node:path";
import * as url from "node:url";
/*
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { app, BrowserWindow } = require("electron");
// eslint-disable-next-line @typescript-eslint/no-require-imports
const serve = require("electron-serve");
// eslint-disable-next-line @typescript-eslint/no-require-imports
const path = require("path");
*/
const __dirname = import.meta.dirname;
function createWindow() {
const win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
//preload: 'preload.js', // If you need a preload script
nodeIntegration: false, // Important for security
contextIsolation: true, // Important for security
},
});
// Load your Next.js app
if(isDev) {
win.loadURL('http://localhost:3000')
}
else {
win.loadURL(`file://${__dirname}/out/index.html`);
}
if (isDev) {
win.webContents.openDevTools(); // Open DevTools in development
// eslint-disable-next-line @typescript-eslint/no-unused-vars
win.webContents.on("did-fail-load", (e, code, desc) => {
win.webContents.reloadIgnoringCache();
});
}
}
app.whenReady().then(() => {
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});