-
Notifications
You must be signed in to change notification settings - Fork 54
/
share.js
47 lines (36 loc) · 1.04 KB
/
share.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
const electron = require('electron');
const fs = require('fs');
const path = require('path');
const url = require('url');
const BrowserWindow = electron.BrowserWindow;
const ipcMain = electron.ipcMain;
let shareWindow = null;
ipcMain.on('open-share-window', openShareWindow);
function openShareWindow () {
if(shareWindow !== null) {
shareWindow.show();
return;
}
shareWindow = new BrowserWindow({width: 1280, height: 820, show: false});
shareWindow.loadURL(url.format({
pathname: path.join(__dirname, 'views','share.html'),
protocol: 'file:',
slashes: true
}));
shareWindow.once('ready-to-show', function () {
shareWindow.show()
});
shareWindow.on('closed', function () {
shareWindow = null
});
}
ipcMain.on('tracking', (event, data) => {
if(shareWindow !== null && data.length > 0) {
try {
shareWindow.webContents.send('tracking', data);
}
catch(err) {
console.log('Window was closed');
}
}
});