1
1
import { app , BrowserWindow } from 'electron' ;
2
- import installExtension , { REACT_DEVELOPER_TOOLS } from 'electron-devtools-installer' ;
3
- import { enableLiveReload } from 'electron-compile ';
2
+
3
+ const APP_URL = 'https://app.httptoolkit.tech ';
4
4
5
5
// Keep a global reference of the window object, if you don't, the window will
6
6
// be closed automatically when the JavaScript object is garbage collected.
7
7
let mainWindow : Electron . BrowserWindow | null = null ;
8
8
9
- const isDevMode = process . execPath . match ( / [ \\ / ] e l e c t r o n / ) ;
10
-
11
- if ( isDevMode ) {
12
- enableLiveReload ( { strategy : 'react-hmr' } ) ;
13
- }
14
-
15
9
const createWindow = async ( ) => {
16
- // Create the browser window.
17
- mainWindow = new BrowserWindow ( {
18
- width : 800 ,
19
- height : 600 ,
20
- } ) ;
21
-
22
- // and load the index.html of the app.
23
- mainWindow . loadURL ( `file://${ __dirname } /index.html` ) ;
24
-
25
- // Open the DevTools.
26
- if ( isDevMode ) {
27
- await installExtension ( REACT_DEVELOPER_TOOLS ) ;
28
- mainWindow . webContents . openDevTools ( ) ;
29
- }
30
-
31
- // Emitted when the window is closed.
32
- mainWindow . on ( 'closed' , ( ) => {
33
- // Dereference the window object, usually you would store windows
34
- // in an array if your app supports multi windows, this is the time
35
- // when you should delete the corresponding element.
36
- mainWindow = null ;
37
- } ) ;
10
+ mainWindow = new BrowserWindow ( {
11
+ width : 800 ,
12
+ height : 600 ,
13
+ webPreferences : {
14
+ nodeIntegration : false
15
+ }
16
+ } ) ;
17
+
18
+ mainWindow . loadURL ( APP_URL ) ;
19
+
20
+ mainWindow . on ( 'closed' , ( ) => {
21
+ mainWindow = null ;
22
+ } ) ;
38
23
} ;
39
24
40
- // This method will be called when Electron has finished
41
- // initialization and is ready to create browser windows.
42
- // Some APIs can only be used after this event occurs.
43
25
app . on ( 'ready' , createWindow ) ;
44
26
45
- // Quit when all windows are closed.
46
27
app . on ( 'window-all-closed' , ( ) => {
47
- // On OS X it is common for applications and their menu bar
48
- // to stay active until the user quits explicitly with Cmd + Q
49
- if ( process . platform !== 'darwin' ) {
50
- app . quit ( ) ;
51
- }
28
+ // On OS X it is common for applications and their menu bar
29
+ // to stay active until the user quits explicitly with Cmd + Q
30
+ if ( process . platform !== 'darwin' ) {
31
+ app . quit ( ) ;
32
+ }
52
33
} ) ;
53
34
54
35
app . on ( 'activate' , ( ) => {
55
- // On OS X it's common to re-create a window in the app when the
56
- // dock icon is clicked and there are no other windows open.
57
- if ( mainWindow === null ) {
58
- createWindow ( ) ;
59
- }
60
- } ) ;
61
-
62
- // In this file you can include the rest of your app's specific main process
63
- // code. You can also put them in separate files and import them here.
36
+ // On OS X it's common to re-create a window in the app when the
37
+ // dock icon is clicked and there are no other windows open.
38
+ if ( mainWindow === null ) {
39
+ createWindow ( ) ;
40
+ }
41
+ } ) ;
0 commit comments