-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
59 lines (40 loc) · 1.2 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
import { BrowserWindow, app } from 'electron';
import windowStateKeeper from 'electron-window-state';
require('electron-reload')(__dirname);
app.on('ready', () => {
let mainWindowState = windowStateKeeper({
defaultWidth: 900,
defaultHeight: 600,
});
let win = new BrowserWindow({
width: mainWindowState.width,
height: mainWindowState.height,
x: mainWindowState.x,
y: mainWindowState.y,
show:false
});
let splashWin=new BrowserWindow({
width:500,
height:400,
frame:false
});
let mainContent=win.webContents;
mainContent.on('new-window',(event,url)=>{
event.preventDefault();
let w=new BrowserWindow({width:800,height:600,show:false});
w.once('ready-to-show',()=>w.show());
w.loadURL(url);
event.newGuest=w;
})
win.on('closed',()=>{
app.quit();
});
splashWin.on('closed',()=>splashWin=null);
win.on('ready-to-show',()=>{
win.show();
splashWin.destroy();
});
win.loadURL(`file://${__dirname}/index.html`);
splashWin.loadURL(`file://${__dirname}/loading.html`);
mainWindowState.manage(win);
});