Electron uses electron-updater to update

The main solution here is to let users choose whether to update, which is more friendly.

 

     autoUpdater.autoDownload = false //这句代码很重要
    autoUpdater.on('error', function(error) {
        sendUpdateMessage(message.error)
    });
    autoUpdater.on('checking-for-update', function() {

        sendUpdateMessage(message.checking)
    });
    autoUpdater.on('update-available', function(info) {
        const options = {
            type: 'info',
            title: '更新提示',
            message: "有新版本需要更新",
            buttons: ['现在更新', '稍后']
        }
        dialog.showMessageBox(options, function(index) {
            if (index == 0) {
                sendUpdateMessage("开始更新")
                autoUpdater.downloadUpdate();//还有这句
            }
        })


    });

 

Built-in autoUpdater and electron-update update

 

Reference: https://segmentfault.com/a/1190000010271226

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325949979&siteId=291194637