-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
60 lines (54 loc) · 1.47 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
const { app, BrowserWindow, Menu } = require('electron')
const ipcMain = require('electron').ipcMain
const path = require('path')
const debug = /--debug/.test(process.argv[2])
function createWindow () {
const windowOptions = {
width: 1200,
height: 960,
minWidth: 1080,
title: app.getName(),
center: true,
resizable: true,
closable: true,
icon: path.resolve(__dirname, '/app.ico'),
backgroundColor: '#f0f0f0',
hasShadow: true,
webPreferences: {
nodeIntegration: true,
webSecurity: false
},
// frame:false, // 隐藏状态栏
// titleBarStyle: 'hidden' //mac隐藏状态栏
}
let win = new BrowserWindow(windowOptions)
menuConfig = []
const menu = Menu.buildFromTemplate(menuConfig)
Menu.setApplicationMenu(menu)
win.loadFile('./react-dev/dist/index.html')
if (debug) {
win.webContents.openDevTools()
}
win.on('closed', () => {
win = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (win === null) {
createWindow()
}
})
ipcMain.on('asynchronous-message', function(event, arg) {
console.log(arg)
event.sender.send('asynchronous-reply', 'pong')
})
ipcMain.on('synchronous-message', (event, arg) => {
console.log(arg)
event.returnValue = 'pong'
})