-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
81 lines (67 loc) · 1.79 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
77
78
79
80
81
const { app, BrowserWindow, Menu, ipcMain } = require('electron');
const { autoUpdater } = require('electron-updater');
const path = require('path');
if (require("electron-squirrel-startup")) {
app.quit();
}
// require('electron-reload')(__dirname, {
// electron: path.join(__dirname, 'node_modules', '.bin', 'electron')
// });
let mainWindow;
app.on('ready', () => {
Menu.setApplicationMenu(null);
mainWindow = new BrowserWindow({
width: 1280,
height: 720,
minWidth: 1100,
minHeight: 700,
frame: false,
darkTheme: true,
vibrancy: 'fullscreen-ui',
backgroundMaterial: 'acrylic',
maximizable: false,
icon: path.join(__dirname, 'icon.ico'),
webPreferences: {
nodeIntegration: true,
contextIsolation: true,
webviewTag: true,
preload: path.join(__dirname, 'preload.js'),
},
});
mainWindow.loadFile(path.join(__dirname, 'index.html'));
mainWindow.on('closed', function () {
mainWindow = null;
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
ipcMain.on('minimize-window', () => {
if (mainWindow) mainWindow.minimize();
});
ipcMain.on('maximize-window', () => {
if (mainWindow) {
if (mainWindow.isMaximized()) {
mainWindow.unmaximize();
} else {
mainWindow.maximize();
}
}
});
ipcMain.on('close-window', () => {
if (mainWindow) mainWindow.close();
});
app.on('ready', () => {
autoUpdater.checkForUpdatesAndNotify();
});
autoUpdater.on('update-available', () => {
console.log("Update Available");
mainWindow.webContents.send('update_available');
});
autoUpdater.on('update-downloaded', () => {
console.log('Update Downloaded; Installing...');
mainWindow.webContents.send('update_downloaded');
autoUpdater.quitAndInstall();
});