-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathmain.js
52 lines (41 loc) · 1.21 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
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
if (process.env.NODE_ENV === 'development') {
require('electron-reload')(__dirname, {
electron: require(`${__dirname}/node_modules/electron`)
})
}
let mainWindow
function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600, icon: './cpu.png'})
// and load the index.html of the app.
if (process.env.NODE_ENV === 'development') {
mainWindow.loadURL(`http://localhost:3000`)
} else {
mainWindow.loadURL(`file://${__dirname}/index.html`)
}
// Open the DevTools.
if (process.env.NODE_ENV === 'development') {
mainWindow.webContents.openDevTools()
}
// Emitted when the window is closed.
mainWindow.on('closed', function () {
mainWindow = null
})
}
// This method will be called when Electron has finished
app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
if (mainWindow === null) {
createWindow()
}
})