简体   繁体   English

Electron autoupdater进度条

[英]Electron autoupdater progress bar

is there any way to set up a progress bar for downloading new update of app in Electron? 有没有办法设置一个进度条,用于在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. 我正在使用Squirrel和electron-simple-updater开发Windows应用electron-simple-updater ,我的问题是更新程序只在它开始下载更新和完成时发出事件。 My update is kinda large (around 80MB) and for users with slow ISPs it kinda sux :( 我的更新有点大(约80MB),对于ISP较慢的用户,它有点sux :(

Maybe this link gives what you want 也许这个链接提供了你想要的东西

https://github.com/iffy/electron-updater-example/blob/master/main.js 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 使用此代码,可以看到日志以查看下载的进度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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