@@ -7,8 +7,8 @@ import { createProtocol, installVueDevtools } from 'vue-cli-plugin-electron-buil
77
88const isDevelopment = process . env . NODE_ENV !== 'production' ;
99if ( isDevelopment ) {
10- // Don't load any native (external) modules until the following line is run:
11- require ( 'module' ) . globalPaths . push ( process . env . NODE_MODULES_PATH ) ;
10+ // Don't load any native (external) modules until the following line is run:
11+ require ( 'module' ) . globalPaths . push ( process . env . NODE_MODULES_PATH ) ;
1212}
1313
1414// global reference to mainWindow (necessary to prevent window from being garbage collected)
@@ -17,60 +17,60 @@ let mainWindow;
1717// Standard scheme must be registered before the app is ready
1818protocol . registerStandardSchemes ( [ 'app' ] , { secure : true } ) ;
1919function createMainWindow ( ) {
20- const window = new BrowserWindow ( ) ;
20+ const window = new BrowserWindow ( ) ;
2121
22- if ( isDevelopment ) {
23- // Load the url of the dev server if in development mode
24- window . loadURL ( process . env . WEBPACK_DEV_SERVER_URL ) ;
25- if ( ! process . env . IS_TEST ) {
26- window . webContents . openDevTools ( ) ;
27- }
28- } else {
29- createProtocol ( 'app' ) ;
30- // Load the index.html when not in development
31- window . loadURL (
32- formatUrl ( {
33- pathname : path . join ( __dirname , 'index.html' ) ,
34- protocol : 'file' ,
35- slashes : true ,
36- } )
37- ) ;
38- }
22+ if ( isDevelopment ) {
23+ // Load the url of the dev server if in development mode
24+ window . loadURL ( process . env . WEBPACK_DEV_SERVER_URL ) ;
25+ if ( ! process . env . IS_TEST ) {
26+ window . webContents . openDevTools ( ) ;
27+ }
28+ } else {
29+ createProtocol ( 'app' ) ;
30+ // Load the index.html when not in development
31+ window . loadURL (
32+ formatUrl ( {
33+ pathname : path . join ( __dirname , 'index.html' ) ,
34+ protocol : 'file' ,
35+ slashes : true ,
36+ } )
37+ ) ;
38+ }
3939
40- window . on ( 'closed' , ( ) => {
41- mainWindow = null ;
42- } ) ;
40+ window . on ( 'closed' , ( ) => {
41+ mainWindow = null ;
42+ } ) ;
4343
44- window . webContents . on ( 'devtools-opened' , ( ) => {
45- window . focus ( ) ;
46- setImmediate ( ( ) => {
47- window . focus ( ) ;
48- } ) ;
49- } ) ;
44+ window . webContents . on ( 'devtools-opened' , ( ) => {
45+ window . focus ( ) ;
46+ setImmediate ( ( ) => {
47+ window . focus ( ) ;
48+ } ) ;
49+ } ) ;
5050
51- return window ;
51+ return window ;
5252}
5353
5454// quit application when all windows are closed
5555app . on ( 'window-all-closed' , ( ) => {
56- // on macOS it is common for applications to stay open until the user explicitly quits
57- if ( process . platform !== 'darwin' ) {
58- app . quit ( ) ;
59- }
56+ // on macOS it is common for applications to stay open until the user explicitly quits
57+ if ( process . platform !== 'darwin' ) {
58+ app . quit ( ) ;
59+ }
6060} ) ;
6161
6262app . on ( 'activate' , ( ) => {
63- // on macOS it is common to re-create a window even after all windows have been closed
64- if ( mainWindow === null ) {
65- mainWindow = createMainWindow ( ) ;
66- }
63+ // on macOS it is common to re-create a window even after all windows have been closed
64+ if ( mainWindow === null ) {
65+ mainWindow = createMainWindow ( ) ;
66+ }
6767} ) ;
6868
6969// create main BrowserWindow when electron is ready
7070app . on ( 'ready' , async ( ) => {
71- if ( isDevelopment && ! process . env . IS_TEST ) {
72- // Install Vue Devtools
73- await installVueDevtools ( ) ;
74- }
75- mainWindow = createMainWindow ( ) ;
71+ if ( isDevelopment && ! process . env . IS_TEST ) {
72+ // Install Vue Devtools
73+ await installVueDevtools ( ) ;
74+ }
75+ mainWindow = createMainWindow ( ) ;
7676} ) ;
0 commit comments