-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
43 lines (36 loc) · 1.07 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
const {app, BrowserWindow, ipcMain} = require('electron');
const path = require('path');
const cp = require('child_process');
const shutdown = require('electron-shutdown-command');
let mainWindow;
app.on('ready', init);
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit();
});
app.on('activate', function () {
if (mainWindow === null) init();
});
function init() {
mainWindow = new BrowserWindow({
title: 'Таймер выключения PC',
icon: './assets/img/icon16.png',
width: 500,
height: 352,
center: true,
resizable: false,
backgroundColor: '#1B2D3C',
autoHideMenuBar: true,
darkTheme: true,
webPreferences: {
preload: path.join(__dirname, 'assets/js/preload.js')
}
});
mainWindow.loadFile('./index.html');
mainWindow.on('closed', () => { mainWindow = null; })
ipcMain.on('shutdown', (ev, data) => {
shutdown.shutdown({
force: true,
quitapp: true
});
});
}