-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
106 lines (86 loc) · 3.1 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const { app, BrowserView, BrowserWindow } = require('electron')
const path = require('path')
require('electron-reload')(__dirname);
require("chokidar");
function refresh(view) {
view.webContents.reload()
}
function StartWatcher(path, view){
var chokidar = require("chokidar");
var watcher = chokidar.watch(path, {
ignored: /[\/\\]\./,
persistent: true
});
function onWatcherReady(){
console.info('From here can you check for real changes, the initial scan has been completed.');
}
// Declare the listeners of the watcher
watcher
.on('add', function(path) {
console.log('File', path, 'has been added');
})
.on('addDir', function(path) {
console.log('Directory', path, 'has been added');
})
.on('change', function(path) {
console.log('File', path, 'has been changed');
refresh(view)
})
.on('unlink', function(path) {
console.log('File', path, 'has been removed');
})
.on('unlinkDir', function(path) {
console.log('Directory', path, 'has been removed');
})
.on('error', function(error) {
console.log('Error happened', error);
})
.on('ready', onWatcherReady)
.on('raw', function(event, path, details) {
// This event should be triggered everytime something happens.
console.log('Raw event info:', event, path, details);
});
}
function createWindow (win, view1, view2) {
win.addBrowserView(view1)
win.addBrowserView(view2)
//win.maximize();
//win.setResizable(false);
const { screen } = require('electron')
// Create a window that fills the screen's available work area.
const primaryDisplay = screen.getPrimaryDisplay()
const { width, height } = primaryDisplay.workAreaSize
//let [width, height] = win.getSize();
console.log(`width: ${width}, height: ${height}`);
var hafwidth = width / 2;
var leftover = width - hafwidth;
view1.setBounds({ x: 0, y: 0, width: hafwidth, height: height })
view1.setAutoResize({width:true, height:true})
view2.setBounds({ x: hafwidth, y: 0, width: leftover, height: height })
view2.setAutoResize({width:true, height:true})
win.show();
}
app.commandLine.appendSwitch("disable-gpu");
app.whenReady().then(() => {
const win = new BrowserWindow({
show: false,
frame: false,
width: 1824,
height: 984,
fullscreen: true, //disable on windows
backgroundColor: '#223b61',
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
const view1 = new BrowserView()
const view2 = new BrowserView()
createWindow(win, view1, view2)
view1.webContents.loadURL(`file://${__dirname}/index.html`)
view2.webContents.loadURL('https://app.dataminr.com/app/dashboard.html')
var screendir = __dirname + "/screenshots"
StartWatcher(screendir, view1)
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})