-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.js
More file actions
42 lines (36 loc) · 1.16 KB
/
main.js
File metadata and controls
42 lines (36 loc) · 1.16 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
const { app, BrowserWindow, ipcMain } = require('electron')
const path = require('path');
function createWindow() {
mainWindow = new BrowserWindow({
width: 1920,
height: 1080,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
preload: path.join(__dirname, 'src', 'preload.js')
},
icon: path.join(__dirname, 'src', 'resources', 'logo.ico'),
autoHideMenuBar: true,
});
mainWindow.on('blur', () => { mainWindow.webContents.send('updateFocus', false) });
mainWindow.on('focus', () => { mainWindow.webContents.send('updateFocus', true) });
mainWindow.loadFile(path.join(__dirname, 'src', 'index.html'));
}
app.whenReady().then(async () => {
createWindow();
app.setAppUserModelId(app.name);
ipcMain.on('focusWindow', () => {
console.log("Focusing?");
mainWindow.focus();
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
app.on('window-all-closed', async () => {
if (process.platform !== 'darwin') {
app.quit();
}
});