-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain_dev.js
More file actions
76 lines (65 loc) · 1.89 KB
/
Copy pathmain_dev.js
File metadata and controls
76 lines (65 loc) · 1.89 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const { app, BrowserWindow, ipcMain, shell } = require("electron");
const previewServer = require("./preview_server_main.js");
const guess_shell_path = function(){
if (process.platform == "win32") {
return process.env["ComSpec"];
} else {
return process.env["SHELL"];
}
};
if (process.argv.includes("--hot-reload")) {
try {
require("electron-reloader")(module);
} catch {}
}
require("@electron/remote/main").initialize();
app.commandLine.appendSwitch("gtk-version", "3");
app.commandLine.appendSwitch("remote-debugging-port", "9541");
/** @type {BrowserWindow | null | undefined} */
let win;
const createWindow = () => {
win = new BrowserWindow({
width: 1200,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
minWidth: 800,
minHeight: 600
});
require("@electron/remote/main").enable(win.webContents);
win.loadFile("./App/start.html");
win.webContents.setWindowOpenHandler(({ url }) => {
if (url.startsWith("http://") || url.startsWith("https://")) {
shell.openExternal(url);
return { action: "deny" };
}
let new_win = new BrowserWindow({
width: 1200,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
},
minWidth: 800,
minHeight: 600
});
require("@electron/remote/main").enable(new_win.webContents);
new_win.loadURL(url);
new_win.webContents.openDevTools();
return { action: "deny" };
});
win.webContents.openDevTools();
};
ipcMain.handle("preview-server:get-info", async () => {
await previewServer.initPreviewPort();
return previewServer.getPreviewServerInfo();
});
ipcMain.handle("preview-server:serve-directory", async (event, rootDir) => {
return previewServer.serveDirectory(rootDir);
});
app.whenReady().then(async () => {
await previewServer.initPreviewPort();
createWindow();
});