简体   繁体   中英

Electron autoupdater progress bar

is there any way to set up a progress bar for downloading new update of app in Electron? I am developing app for Windows using Squirrel and electron-simple-updater and my problem is that updater only gives out events when it starts to download update and when it finishes. My update is kinda large (around 80MB) and for users with slow ISPs it kinda sux :(

Maybe this link gives what you want

https://github.com/iffy/electron-updater-example/blob/master/main.js

autoUpdater.on('download-progress', (ev, progressObj) => {
  sendStatusToWindow('Download progress...');
})
const log = require('electron-log');
const { autoUpdater } = require("electron-updater");
autoUpdater.logger = log;
log.info('App starting...');    
autoUpdater.on('download-progress', (progressObj) => {
    let log_message = "Download speed: " + progressObj.bytesPerSecond;
    log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
    log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
    sendStatusToWindow(log_message);
})

function sendStatusToWindow(text) {
    log.info(text);
    homePageWindow.webContents.send('message', text);
}

With this code the log can be seen to see the progress of the download

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM