-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelectron.js
More file actions
56 lines (46 loc) · 1.31 KB
/
electron.js
File metadata and controls
56 lines (46 loc) · 1.31 KB
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
const { app, BrowserWindow, globalShortcut } = require('electron');
function createWindow() {
const mainWindow = new BrowserWindow({
width: 1280,
height: 745,
resizable: false,
webPreferences: {
nodeIntegration: false,
contextIsolation: true
}
});
mainWindow.removeMenu();
mainWindow.loadFile('index.html');
}
app.whenReady().then(() => {
console.log('Electron app is ready');
createWindow();
globalShortcut.register('CommandOrControl+R', () => {
const focusedWindow = BrowserWindow.getFocusedWindow();
if (focusedWindow) {
focusedWindow.reload();
}
});
globalShortcut.register('F12', () => {
const focusedWindow = BrowserWindow.getFocusedWindow();
if (focusedWindow) {
focusedWindow.webContents.toggleDevTools();
}
});
globalShortcut.register('CommandOrControl+Shift+I', () => {
const focusedWindow = BrowserWindow.getFocusedWindow();
if (focusedWindow) {
focusedWindow.webContents.toggleDevTools();
}
});
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on('window-all-closed', function () {
console.log('All windows closed');
if (process.platform !== 'darwin') app.quit();
});
app.on('will-quit', () => {
globalShortcut.unregisterAll();
});