-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
61 lines (51 loc) · 1.41 KB
/
Copy pathmain.js
File metadata and controls
61 lines (51 loc) · 1.41 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
57
58
59
60
61
const { app, BrowserWindow, ipcMain } = require('electron/main')
const windows = []
app.whenReady().then(() => {
const mainWindow = new BrowserWindow({
width: 1200,
height: 800,
frame: false,
titleBarStyle: 'hidden',
transparent: false,
resizable: true,
maximizable: true,
minimizable: true,
alwaysOnTop: false,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
preload: __dirname + '/preload.js'
}
})
windows.push(mainWindow)
mainWindow.loadFile('index.html')
// Обработчики для кнопок управления окном
ipcMain.on('minimize-window', () => {
mainWindow.minimize()
})
ipcMain.on('maximize-window', () => {
if (mainWindow.isMaximized()) {
mainWindow.unmaximize()
} else {
mainWindow.maximize()
}
})
ipcMain.on('close-window', () => {
mainWindow.close()
})
ipcMain.on('reload-window', () => {
mainWindow.reload()
})
// Отправляем состояние максимизации в рендерер
mainWindow.on('maximize', () => {
mainWindow.webContents.send('update-maximize', true)
})
mainWindow.on('unmaximize', () => {
mainWindow.webContents.send('update-maximize', false)
})
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})