-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
61 lines (51 loc) · 1.42 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
require('./server.js');
const {app, BrowserWindow, ipcMain} = require('electron');
const path = require('path');
const { env } = require('process');
let mainWindow = null;
ipcMain.on('close', app.quit);
ipcMain.on('minimize', () => mainWindow.minimize());
exports.getWindow = () => mainWindow;
function createWindow() {
// Create the browser window.
const mainWindow = new BrowserWindow({
icon: path.resolve(__dirname, './app/bg.png'),
width: 600,
height: 180,
minHeight: 180,
maxHeight: 180,
minWidth: 500,
frame: false,
transparent: true,
alwaysOnTop: true,
maximizable: false,
hasShadow: false,
webPreferences: {
nodeIntegration: true
}
});
// and load the index.html of the app.
mainWindow.setMenu(null);
function openWindow() {
mainWindow.loadFile('app/index.html');
if (process.env.NODE_ENV === 'development') {
mainWindow.webContents.openDevTools();
}
}
openWindow();
ipcMain.on('re-render', openWindow);
return mainWindow;
}
app.whenReady().then(() => {
mainWindow = createWindow();
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) {
mainWindow = createWindow();
}
});
});
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit();
}
});