@@ -154,13 +154,21 @@ function createMainWindow() {
154154 mainWindow . on ( 'close' , ( event ) => {
155155 event . preventDefault ( ) ;
156156 if ( isDev || forceDevtools ) mainWindow . webContents . closeDevTools ( ) ;
157- app . isHidden = true ;
158- if ( process . platform !== 'darwin' ) {
159- mainWindow . setSkipTaskbar ( true ) ;
157+
158+ const needCloseApp =
159+ appConfig . getSync ( 'general.quitAtClose' ) || false ;
160+
161+ if ( ! needCloseApp ) {
162+ app . isHidden = true ;
163+ if ( process . platform !== 'darwin' ) {
164+ mainWindow . setSkipTaskbar ( true ) ;
165+ } else {
166+ app . dock . hide ( ) ;
167+ }
168+ mainWindow . hide ( ) ;
160169 } else {
161- app . dock . hide ( ) ;
170+ app . quit ( ) ;
162171 }
163- mainWindow . hide ( ) ;
164172 } ) ;
165173}
166174
@@ -298,6 +306,7 @@ function setInitialValues() {
298306 lastCheck : Date . now ( ) ,
299307 enableMetrics : true ,
300308 openAtLogin : true ,
309+ quitAtClose : false ,
301310 } ,
302311 invoice : {
303312 exportDir : os . homedir ( ) ,
@@ -481,8 +490,8 @@ function migrateData() {
481490 } ,
482491 6 : ( configs ) => {
483492 // Return current configs if this is the first time install
484- const { trayIcon , enableMetrics } = configs . general ;
485- if ( trayIcon !== undefined && enableMetrics !== undefined ) {
493+ const { openAtLogin } = configs . general ;
494+ if ( openAtLogin !== undefined ) {
486495 return configs ;
487496 }
488497
@@ -495,6 +504,22 @@ function migrateData() {
495504 } ,
496505 } ;
497506 } ,
507+ 7 : ( configs ) => {
508+ // Return current configs if this is the first time install
509+ const { quitAtClose } = configs . general ;
510+ if ( quitAtClose !== undefined ) {
511+ return configs ;
512+ }
513+
514+ // Update current configs
515+ return {
516+ ...configs ,
517+ general : {
518+ ...configs . general ,
519+ quitAtClose : false ,
520+ } ,
521+ } ;
522+ } ,
498523 } ;
499524 // Get the current Config
500525 const configs = appConfig . getSync ( ) ;
0 commit comments