-
Notifications
You must be signed in to change notification settings - Fork 0
/
electron.js
67 lines (56 loc) · 1.59 KB
/
electron.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
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
let mainWindow
let externalWindow
function createWindow() {
let displays = electron.screen.getAllDisplays()
let externalDisplay = displays.find((display) => {
return display.bounds.x !== 0 || display.bounds.y !== 0
})
mainWindow = new BrowserWindow({
width: 800,
height: 600,
kiosk: false,
frame: true,
show: false,
backgroundColor: '#000',
alwaysOnTop: true,
icon: __dirname + 'public/assets/images/favicon.ico'
})
mainWindow.loadURL('http://localhost:50780/')
mainWindow.maximize()
mainWindow.show()
mainWindow.on('closed', function () {
mainWindow = null
})
if (externalDisplay) {
externalWindow = new BrowserWindow({
width: 800,
height: 600,
kiosk: true,
frame: false,
backgroundColor: '#000',
alwaysOnTop: true,
icon: __dirname + 'public/assets/images/favicon.ico',
x: externalDisplay.bounds.x + 50,
y: externalDisplay.bounds.y + 50
})
externalWindow.loadURL('http://localhost:50780/d')
externalWindow.on('closed', function () {
externalWindow = null
})
}
console.log(displays)
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
if (mainWindow === null) {
createWindow()
}
})