-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
80 lines (64 loc) · 1.98 KB
/
index.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
78
79
80
'use strict'
const debug = require('debug')('tc:main')
debug('init')
process.on('exit', function(code) {
debug('process exited with', code)
})
const {app, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url')
let win
function createWindow () {
// Create the browser window.
win = new BrowserWindow({
width: 1200,
height: 800,
show: false
})
//Fetch screen local path and remote uri
let screenPath = path.join(__dirname, '/node_modules/troncast-screen')
let localIp = require('ip').address()
let port = debug.enabled ? 13372 : 13370
let remoteUri = `http://${localIp}:${port}`
let urlQueryString = '?localPath='+encodeURIComponent(screenPath)+'&remoteUri='+encodeURIComponent(remoteUri)
if (debug.enabled){
win.loadURL(`http://localhost:13371${urlQueryString}`)
}else{
win.loadURL(`file://${screenPath}/dist/index.html${urlQueryString}`.replace(/\\/g,'/'))
}
if (!debug.enabled){
require('troncast-server')
}
//Load vue devtools
if (debug.enabled){
const devtoolsInstaller = require('electron-devtools-installer')
devtoolsInstaller.default(devtoolsInstaller.VUEJS_DEVTOOLS)
.then((name) => {
debug('dev-tool','Added Extension:',name)
// Open the DevTools
win.webContents.openDevTools()
})
.catch((err) => debug('dev-tool','An error occurred:', err))
}
win.once('ready-to-show', () => {
debug('ready-to-show','URL loaded:',win.getURL())
win.show()
})
// Emitted when the window is closed.
win.on('closed', () => {
win = null
})
}
app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
//macOS especific
app.on('activate', () => {
if (win === null) {
createWindow()
}
})