1- const { app, BrowserWindow, ipcMain } = require ( 'electron' ) ;
1+ const electron = require ( 'electron' )
2+ const { app, BrowserWindow, ipcMain, ipcRenderer } = require ( "electron" ) ;
3+ const fs = require ( 'fs' ) ;
24const path = require ( 'path' ) ;
3- const { autoUpdater } = require ( "electron-updater" ) ;
5+ const { autoUpdater, AppUpdater } = require ( "electron-updater" ) ;
46
57autoUpdater . autoDownload = true ;
68autoUpdater . autoInstallOnAppQuit = true ;
@@ -16,68 +18,60 @@ function createWindow() {
1618 webPreferences : {
1719 nodeIntegration : true
1820 }
19- } ) ;
21+ } )
22+
23+ win . loadFile ( './html/index.html' )
2024
21- const splash = new BrowserWindow ( {
25+ var splash = new BrowserWindow ( {
2226 width : 528 ,
2327 height : 322 ,
2428 transparent : true ,
2529 frame : false ,
26- alwaysOnTop : true ,
27- show : true
30+ webPreferences : {
31+ nodeIntegration : true
32+ }
2833 } ) ;
2934
3035 splash . loadFile ( './html/splash.html' ) ;
36+ splash . center ( ) ;
3137
32- win . loadFile ( './html/index.html' ) ;
38+ setTimeout ( function ( ) {
39+ splash . close ( ) ;
40+ win . show ( ) ;
41+ } , 10000 ) ;
3342
34- win . once ( 'ready-to-show' , ( ) => {
35- if ( ! autoUpdater . downloadProgress ) {
36- splash . hide ( ) ;
37- win . show ( ) ;
38- }
43+ autoUpdater . on ( "download-progress" , ( progressObj ) => {
44+ splash . webContents . send ( 'download-progress' , progressObj ) ;
3945 } ) ;
46+ }
47+
48+ app . whenReady ( ) . then ( ( ) => {
49+ createWindow ( )
4050
4151 autoUpdater . checkForUpdates ( ) ;
4252 console . log ( `Checking for updates. Current version ${ app . getVersion ( ) } ` ) ;
53+ } )
4354
44- autoUpdater . on ( "update-available" , ( info ) => {
45- console . log ( `Update available. Current version ${ app . getVersion ( ) } ` ) ;
46- splash . webContents . send ( 'update-message' , 'An update is available. Downloading now...' ) ;
47- } ) ;
48-
49- autoUpdater . on ( "update-not-available" , ( info ) => {
50- console . log ( `No update available. Current version ${ app . getVersion ( ) } ` ) ;
51- } ) ;
52-
53- autoUpdater . on ( "download-progress" , ( progressObj ) => {
54- splash . webContents . send ( 'update-message' , `Downloading update... ${ progressObj . percent } %` ) ;
55- } ) ;
56-
57- autoUpdater . on ( "update-downloaded" , ( info ) => {
58- console . log ( `Update downloaded. Current version ${ app . getVersion ( ) } ` ) ;
59- splash . webContents . send ( 'update-message' , 'Update downloaded. Installing now...' ) ;
60- autoUpdater . quitAndInstall ( ) ;
61- } ) ;
55+ autoUpdater . on ( "update-available" , ( info ) => {
56+ console . log ( `Update available. Current version ${ app . getVersion ( ) } ` ) ;
57+ } ) ;
6258
63- }
59+ autoUpdater . on ( "update-not-available" , ( info ) => {
60+ console . log ( `No update available. Current version ${ app . getVersion ( ) } ` ) ;
61+ } ) ;
6462
65- app . whenReady ( ) . then ( ( ) => {
66- createWindow ( ) ;
63+ autoUpdater . on ( "update-downloaded" , ( info ) => {
64+ console . log ( `Update downloaded. Current version ${ app . getVersion ( ) } ` ) ;
6765} ) ;
6866
6967app . on ( 'window-all-closed' , ( ) => {
7068 if ( process . platform !== 'darwin' ) {
7169 app . quit ( )
7270 }
73- } ) ;
71+ } )
7472
7573app . on ( 'activate' , ( ) => {
7674 if ( BrowserWindow . getAllWindows ( ) . length === 0 ) {
77- createWindow ( ) ;
75+ createWindow ( )
7876 }
79- } ) ;
80-
81- ipcMain . on ( 'get-app-version' , ( event ) => {
82- event . returnValue = app . getVersion ( ) ;
83- } ) ;
77+ } )
0 commit comments