[英]Electron autoupdater progress bar
有沒有辦法設置一個進度條,用於在Electron下載應用程序的新更新? 我正在使用Squirrel和electron-simple-updater
開發Windows應用electron-simple-updater
,我的問題是更新程序只在它開始下載更新和完成時發出事件。 我的更新有點大(約80MB),對於ISP較慢的用戶,它有點sux :(
也許這個鏈接提供了你想要的東西
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);
}
使用此代碼,可以看到日志以查看下載的進度
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.