-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
76 lines (64 loc) · 1.59 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
const {app, BrowserWindow, Menu, globalShortcut, ipcMain} = require('electron');
const os = require('os');
let win;
function createWindow() {
win = new BrowserWindow({
width: 810,
height: 500,
resizable: false,
'use-content-size': true,
backgroundColor: '#222222',
icon: __dirname + './icons/Sysinfo.png',
title:'System Info',
webPreferences: {
nodeIntegration: true
}
});
win.loadFile('pages/index.html');
ipcMain.on('will-resize', function (e, x, y) {
win.setMinimumSize(810, 300);
win.setMaximumSize(810, 800);
win.setSize(x, y);
});
let platform = os.platform()
var reload = ()=>{
win.webContents.reload();
}
globalShortcut.register('F5', reload);
if (platform === 'darwin') {
globalShortcut.register('Command+Option+I', () => {
win.webContents.toggleDevTools({mode: 'bottom'});
});
} else
if (platform === 'linux' || platform === 'win32') {
globalShortcut.register('Control+Shift+I', () => {
win.webContents.toggleDevTools({mode: 'bottom'});
});
}
win.on('closed', () => {
win = null;
globalShortcut.unregisterAll();
});
const mainMenu = Menu.buildFromTemplate(mainMenuTemplate);
Menu.setApplicationMenu(mainMenu);
}
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if(process.platform !== 'darwin') {
app.quit();
}
});
const mainMenuTemplate = [
{
label: 'File',
submenu:[
{
label: 'Quit',
accelerator:process.platform == 'darwin' ? 'Command+Q' : 'Ctrl+Q',
click(){
app.quit();
}
}
]
}
];