| 
									
										
										
										
											2023-08-28 13:23:10 +02:00
										 |  |  | const { app, BrowserWindow } = require('electron/main') | 
					
						
							| 
									
										
										
										
											2020-11-30 09:48:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-01 19:41:13 -07:00
										 |  |  | let progressInterval | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-30 09:48:39 +02:00
										 |  |  | function createWindow () { | 
					
						
							|  |  |  |   const win = new BrowserWindow({ | 
					
						
							|  |  |  |     width: 800, | 
					
						
							| 
									
										
										
										
											2021-06-01 19:41:13 -07:00
										 |  |  |     height: 600 | 
					
						
							| 
									
										
										
										
											2020-11-30 09:48:39 +02:00
										 |  |  |   }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   win.loadFile('index.html') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-01 19:41:13 -07:00
										 |  |  |   const INCREMENT = 0.03 | 
					
						
							|  |  |  |   const INTERVAL_DELAY = 100 // ms
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   let c = 0 | 
					
						
							|  |  |  |   progressInterval = setInterval(() => { | 
					
						
							|  |  |  |     // update progress bar to next value
 | 
					
						
							|  |  |  |     // values between 0 and 1 will show progress, >1 will show indeterminate or stick at 100%
 | 
					
						
							|  |  |  |     win.setProgressBar(c) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // increment or reset progress bar
 | 
					
						
							|  |  |  |     if (c < 2) { | 
					
						
							|  |  |  |       c += INCREMENT | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       c = (-INCREMENT * 5) // reset to a bit less than 0 to show reset state
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   }, INTERVAL_DELAY) | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-11-30 09:48:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | app.whenReady().then(createWindow) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-01 19:41:13 -07:00
										 |  |  | // before the app is terminated, clear both timers
 | 
					
						
							|  |  |  | app.on('before-quit', () => { | 
					
						
							|  |  |  |   clearInterval(progressInterval) | 
					
						
							|  |  |  | }) | 
					
						
							| 
									
										
										
										
											2020-11-30 09:48:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | app.on('window-all-closed', () => { | 
					
						
							|  |  |  |   if (process.platform !== 'darwin') { | 
					
						
							|  |  |  |     app.quit() | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | app.on('activate', () => { | 
					
						
							|  |  |  |   if (BrowserWindow.getAllWindows().length === 0) { | 
					
						
							|  |  |  |     createWindow() | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }) |