@@ -11,6 +11,7 @@ import { closeLoadingWindow, buildMainWindow } from '../windows/windowManager'
1111import { nextTick } from 'node:process'
1212import { updateLoadingStatus } from '@server/windows/loadingWindow'
1313import { join } from 'node:path'
14+ import { checkFlag } from './lifecycleCheck'
1415
1516/**
1617 * Initialize the application lifecycle
@@ -35,20 +36,28 @@ export async function initializeAppLifecycle(): Promise<void> {
3536 optimizer . watchWindowShortcuts ( window )
3637 } )
3738
39+ const startMinimized = await checkFlag ( 'server_startMinimized' )
3840 // Create main window after loading is complete
39- const mainWindow = buildMainWindow ( )
41+ if ( ! startMinimized ) {
42+ await updateLoadingStatus ( 'Creating main window' )
43+ const mainWindow = buildMainWindow ( )
44+ mainWindow . once ( 'ready-to-show' , async ( ) => {
45+ await updateLoadingStatus ( 'Finishing Up...' )
46+ closeLoadingWindow ( )
47+ mainWindow . show ( )
48+ } )
49+ }
4050
4151 // Load modules and set up IPC handlers
4252 nextTick ( async ( ) => {
4353 await setupIpcHandlers ( )
4454 await loadModules ( )
45- await updateLoadingStatus ( 'Creating main window' )
46- } )
47-
48- mainWindow . once ( 'ready-to-show' , async ( ) => {
49- await updateLoadingStatus ( 'Finishing Up...' )
50- closeLoadingWindow ( )
51- mainWindow . show ( )
55+ if ( startMinimized ) {
56+ await updateLoadingStatus ( 'Start Minimized: TRUE' )
57+ setTimeout ( ( ) => {
58+ closeLoadingWindow ( ) // ensure the loading window is closed
59+ } , 3000 )
60+ }
5261 } )
5362
5463 app . on ( 'before-quit' , async ( ) => {
0 commit comments