-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·73 lines (64 loc) · 1.64 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
const { app, BrowserWindow, screen } = require('electron')
const path = require('path')
let outputWindow
function createMainWindow() {
const mainWindow = new BrowserWindow({
width: 312,
height: 68,
webPreferences: {
contextIsolation: false,
enableRemoteModule: true,
nodeIntegration: true,
preload: path.join(__dirname, 'preload.js')
}
})
mainWindow.loadFile('index.html')
//mainWindow.webContents.openDevTools()
}
function createOutputWindow(pos) {
outputWindow = new BrowserWindow({
x: pos.x,
y: pos.y,
width: 512,
height: 256,
frame: false,
roundedCorners: false,
resizable: false,
webPreferences: {
contextIsolation: false,
enableRemoteModule: true,
nodeIntegration: true,
preload: path.join(__dirname, 'preload.js')
}
})
outputWindow.loadFile('start.html')
}
app.whenReady().then(() => {
createMainWindow()
const displays = screen.getAllDisplays()
const externalDisplay = displays.find((display) => {
return display.bounds.x !== 0 || display.bounds.y !== 0
})
createOutputWindow(externalDisplay.bounds)
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createMainWindow()
})
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
const { ipcMain } = require('electron')
ipcMain.on('update', async (event, args) => {
try {
outputWindow.loadURL(args.url)
event.reply('reply', {
success: true,
message: 'iframe updated'
})
} catch (err) {
event.reply('reply', {
success: false,
message: err.message
})
}
})