1
- const { app, BrowserWindow, Menu } = require ( 'electron' ) ;
1
+ const { app, BrowserWindow, Menu, dialog } = require ( 'electron' ) ;
2
2
const path = require ( 'path' ) ;
3
3
const template = require ( './menubar' ) ;
4
4
const dns = require ( 'dns' ) ;
5
5
const { autoUpdater } = require ( 'electron-updater' ) ;
6
+ const log = require ( 'electron-log' ) ;
6
7
7
8
let mainWindow ;
8
9
9
10
const menu = Menu . buildFromTemplate ( template )
10
11
Menu . setApplicationMenu ( menu )
11
12
13
+ autoUpdater . logger = log ;
14
+ autoUpdater . logger . transports . file . level = 'info' ;
15
+
12
16
function createWindow ( ) {
13
17
mainWindow = new BrowserWindow ( {
14
18
width : 1280 ,
@@ -17,7 +21,7 @@ function createWindow() {
17
21
frame : true ,
18
22
autoHideMenuBar : true , // Automatically hide the menu bar
19
23
webPreferences : {
20
- nodeIntegration : false ,
24
+ nodeIntegration : true ,
21
25
}
22
26
} ) ;
23
27
@@ -45,25 +49,40 @@ app.whenReady().then(() => {
45
49
createWindow ( ) ;
46
50
}
47
51
} ) ;
48
-
49
- // Check for updates
52
+
50
53
autoUpdater . checkForUpdatesAndNotify ( ) ;
51
54
} ) ;
52
55
53
56
autoUpdater . on ( 'update-available' , ( ) => {
54
57
console . log ( 'Update available!' ) ;
58
+ dialog . showMessageBox ( {
59
+ type : 'info' ,
60
+ title : 'Update Available' ,
61
+ message : 'An update is available and is being downloaded.' ,
62
+ } ) ;
55
63
} ) ;
56
64
57
65
autoUpdater . on ( 'update-not-available' , ( ) => {
58
66
console . log ( 'No updates available.' ) ;
67
+ dialog . showMessageBox ( {
68
+ type : 'info' ,
69
+ title : 'No Updates' ,
70
+ message : 'Your application is up-to-date.' ,
71
+ } ) ;
59
72
} ) ;
60
73
61
74
autoUpdater . on ( 'error' , ( err ) => {
62
75
console . error ( 'Error checking for updates:' , err ) ;
76
+ dialog . showErrorBox ( 'Update Error' , 'An error occurred while checking for updates. Please check the logs for more details.' ) ;
63
77
} ) ;
64
78
65
79
autoUpdater . on ( 'update-downloaded' , ( ) => {
66
80
console . log ( 'Update downloaded. It will be installed on restart.' ) ;
81
+ dialog . showMessageBox ( {
82
+ type : 'info' ,
83
+ title : 'Update Ready' ,
84
+ message : 'Update downloaded. It will be installed on restart.' ,
85
+ } ) ;
67
86
} ) ;
68
87
69
88
app . on ( 'window-all-closed' , ( ) => {
0 commit comments