Electron 使用electron-updater更新

这里主要解决让用户是否选择更新,更加友好。

     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();//还有这句
            }
        })


    });

自带的autoUpdater和electron-update更新

参考资料:https://segmentfault.com/a/1190000010271226

猜你喜欢

转载自my.oschina.net/u/554046/blog/1796574