-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.js
77 lines (65 loc) · 1.82 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const { app, BrowserWindow, ipcRenderer, ipcMain } = require('electron')
const path = require('path')
try {
require("electron-reloader")(module);
} catch (_) {}
var wind = null;
let subwindows = [];
const createWindow = () => {
const win = new BrowserWindow({
width: 1800,
height: 1000,
autoHideMenuBar: false, // TODO just for debugging purposes of the packaged app
fullscreen: false, // just for debugging TODO
frame: true, // just for debugging
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
nodeIntegration: true,
contextIsolation: false,
nodeIntegrationInSubFrames: true,
},
titleBarOverlay: {
color: '#2f3241',
symbolColor: '#74b1be'
}
});
win.addListener("close", (e) => {
subwindows.map(v => {
try {
v.close();
} catch (error) {
console.log("already destroyed")
}
});
});
win.loadFile('index.html')
wind = win;
}
app.whenReady().then(() => {
ipcMain.handle("plugin:open", openPlugin)
ipcMain.handle("test", openWindow)
createWindow()
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
})
function openPlugin(event, name) {
const tmp = new BrowserWindow({
width: 600,
height: 200,
autoHideMenuBar: true,
title: name,
});
tmp.loadFile("./"+name+"/index.html");
subwindows.push(tmp);
}
function openWindow(event, title, options, folder) {
const tmp = new BrowserWindow(options);
tmp.setParentWindow(wind);
// put those other windows in folders with index.html files too
tmp.loadFile(folder+"/index.html");
//tmp.webContents.send(title);
//ipcMain.emit(this.id);
}