@@ -3,6 +3,7 @@ import { createRequire } from 'node:module'
3
3
import type {
4
4
ProgressInfo ,
5
5
UpdateDownloadedEvent ,
6
+ UpdateInfo ,
6
7
} from 'electron-updater'
7
8
8
9
const { autoUpdater } = createRequire ( import . meta. url ) ( 'electron-updater' ) ;
@@ -17,11 +18,11 @@ export function update(win: Electron.BrowserWindow) {
17
18
// start check
18
19
autoUpdater . on ( 'checking-for-update' , function ( ) { } )
19
20
// update available
20
- autoUpdater . on ( 'update-available' , ( arg ) => {
21
+ autoUpdater . on ( 'update-available' , ( arg : UpdateInfo ) => {
21
22
win . webContents . send ( 'update-can-available' , { update : true , version : app . getVersion ( ) , newVersion : arg ?. version } )
22
23
} )
23
24
// update not available
24
- autoUpdater . on ( 'update-not-available' , ( arg ) => {
25
+ autoUpdater . on ( 'update-not-available' , ( arg : UpdateInfo ) => {
25
26
win . webContents . send ( 'update-can-available' , { update : false , version : app . getVersion ( ) , newVersion : arg ?. version } )
26
27
} )
27
28
@@ -40,7 +41,7 @@ export function update(win: Electron.BrowserWindow) {
40
41
} )
41
42
42
43
// Start downloading and feedback on progress
43
- ipcMain . handle ( 'start-download' , ( event ) => {
44
+ ipcMain . handle ( 'start-download' , ( event : Electron . IpcMainInvokeEvent ) => {
44
45
startDownload (
45
46
( error , progressInfo ) => {
46
47
if ( error ) {
@@ -68,8 +69,8 @@ function startDownload(
68
69
callback : ( error : Error | null , info : ProgressInfo | null ) => void ,
69
70
complete : ( event : UpdateDownloadedEvent ) => void ,
70
71
) {
71
- autoUpdater . on ( 'download-progress' , info => callback ( null , info ) )
72
- autoUpdater . on ( 'error' , error => callback ( error , null ) )
72
+ autoUpdater . on ( 'download-progress' , ( info : ProgressInfo ) => callback ( null , info ) )
73
+ autoUpdater . on ( 'error' , ( error : Error ) => callback ( error , null ) )
73
74
autoUpdater . on ( 'update-downloaded' , complete )
74
75
autoUpdater . downloadUpdate ( )
75
76
}
0 commit comments