@@ -10,6 +10,7 @@ import {
10
10
import { ipcHandlers } from "./helpers/ipcHandlers" ;
11
11
import { autoUpdater } from "electron-updater" ;
12
12
import { initWin } from "./helpers/autoUpdate" ;
13
+ import { port } from "./helpers/settings" ;
13
14
14
15
let win : BrowserWindow | null = null ;
15
16
app . enableSandbox ( ) ;
@@ -29,22 +30,14 @@ app.on("will-finish-launching", () => {
29
30
} ) ;
30
31
} ) ;
31
32
32
- const cert = fs . readFileSync (
33
- path . join (
34
- app . getAppPath ( ) ,
35
- is . development ? `desktop/resources/server.cert` : `../app/server.cert`
36
- ) ,
37
- "utf8"
38
- ) ;
39
- const port = Number ( process . env . PORT ) || 4444 ;
40
-
41
33
async function createWindow ( ) {
42
- await startThoriumServer ( ) ;
43
- ipcHandlers ( ) ;
44
- loaded = true ;
45
- if ( loadedPath ) {
46
- loadFile ( loadedPath ) ;
47
- }
34
+ const cert = fs . readFileSync (
35
+ path . join (
36
+ app . getAppPath ( ) ,
37
+ is . development ? `desktop/resources/server.cert` : `../app/server.cert`
38
+ ) ,
39
+ "utf8"
40
+ ) ;
48
41
// TODO: Manage this with the multi-window manager some day
49
42
app . on (
50
43
"certificate-error" ,
@@ -55,7 +48,7 @@ async function createWindow() {
55
48
callback ( certificate . data === cert ) ;
56
49
}
57
50
) ;
58
- restoreMenubar ( app ) ;
51
+
59
52
win = new BrowserWindow ( {
60
53
width : 1024 ,
61
54
height : 768 ,
@@ -71,33 +64,29 @@ async function createWindow() {
71
64
} ,
72
65
show : false ,
73
66
} ) ;
67
+
74
68
initWin ( win ) ;
75
- win . webContents . setWindowOpenHandler ( ( { url} ) => {
76
- shell . openExternal ( url ) ;
77
- return { action : "deny" } ;
78
- } ) ;
69
+ await win . loadFile ( "index.html" ) ;
70
+ await startThoriumServer ( ) ;
71
+ ipcHandlers ( ) ;
72
+ loaded = true ;
73
+ if ( loadedPath ) {
74
+ loadFile ( loadedPath ) ;
75
+ }
76
+ restoreMenubar ( app ) ;
79
77
80
78
// We add 1 to the port, since we want to connect to the HTTPS server
81
79
// which is 1 more than the default port
82
- win . loadURL ( `http://localhost:${ port } ` ) ;
83
- win . on ( "closed" , ( ) => {
84
- win = null ;
85
- } ) ;
86
- win . on ( "ready-to-show" , ( ) => {
87
- if ( win ) {
88
- win . show ( ) ;
89
- win . focus ( ) ;
90
- }
91
- } ) ;
80
+ await win . loadURL ( `http://0.0.0.0:${ port } ` ) ;
92
81
}
93
82
94
83
app . whenReady ( ) . then ( async ( ) => {
84
+ await createWindow ( ) ;
95
85
try {
96
86
await autoUpdater . checkForUpdatesAndNotify ( ) ;
97
87
} catch ( error ) {
98
88
// Ignore it
99
89
}
100
- await createWindow ( ) ;
101
90
} ) ;
102
91
103
92
app . on ( "window-all-closed" , async ( ) => {
0 commit comments