-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
69 lines (55 loc) · 1.47 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
const {app, BrowserWindow} = require('electron');
const electron = require('electron');
const url = require('url');
const path = require('path');
const { ipcMain } = require('electron');
var ipc = require('electron').ipcMain;
let nodeConsole = require('console');
const appFolder = path.dirname(process.execPath);
const updateExe = path.resolve(appFolder, '..', 'Update.exe');
const exeName = path.basename(process.execPath);
let myConsole = new nodeConsole.Console(process.stdout, process.stderr);
myConsole.log('It works!');
ipc.on('invokeAction', function(event, data) {
let result = processData(data);
event.sender.send('actionReply', result);
});
app.setLoginItemSettings({
openAtLogin: true,
path: updateExe,
args: [
'--processStart', `"${exeName}"`,
'--process-start-args', `"--hidden"`
]
});
function createWindow() {
let { width, height } = electron.screen.getPrimaryDisplay().workAreaSize;
let win = new BrowserWindow({
width: 290,
height: 145,
x: width - 300,
y: height - 1020,
transparent: true,
frame: false,
skipTaskbar: true,
webPreferences: {
nodeIntegration: true
}
});
win.setResizable(false);
win.loadFile('index.html');
win.on('closed', () => {
win = null;
});
}
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (win === null) {
createWindow();
}
});