Electron 使用electron-updater更新

這裏主要解決讓用戶是否選擇更新,更加友好。javascript

 

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更新java

 

參考資料:https://segmentfault.com/a/1190000010271226segmentfault

相關文章
相關標籤/搜索