-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (41 loc) 路 1016 Bytes
/
index.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
/**
* Created by shu on 7/3/2017.
*/
const {app, BrowserWindow} = require('electron')
const createRPC = require('./src/common/rpc')
const fontLoader = require('./src/common/loader')
app.commandLine.appendSwitch('--enable-experimental-web-platform-features')
app.on('window-all-closed', function () {
app.quit()
})
app.on('ready', function () {
mainWindow = new BrowserWindow({
width: 800,
height: 600,
show: false,
titleBarStyle: 'hidden-inset',
minHeight: 190,
minWidth: 550,
webPreferences: {
experimentalFeatures: true
}
})
mainWindow.loadURL(`file://${__dirname}/src/view/index.html`)
mainWindow.on('closed', function () {
mainWindow = null
app.quit()
})
// mainWindow.webContents.openDevTools()
const rpc = createRPC(mainWindow)
start(rpc)
})
function start(rpc) {
rpc.on('init', () => {
mainWindow.show()
})
rpc.on('load_fonts', () => {
fontLoader.load().then(fonts => {
rpc.send('fonts_loaded', fonts)
})
})
}