electron-vue + autoUpdater 自动更新,检测到最新版本,没有下载
根据网上的代码,求大神讲解
updateHandle()
function updateHandle(){
const os = require('os');
const uploadUrl = "http://127.0.0.1:5000/download/"; // 下载地址,不加后面的.exe
autoUpdater.setFeedURL(uploadUrl);
autoUpdater.on('error', function (error) {
console.log("错误信息提示:",error)
sendUpdateMessage('检查更新出错')
})
autoUpdater.on('checking-for-update', function () {
sendUpdateMessage('正在检查更新……')
})
autoUpdater.on('update-available', function (info) {
sendUpdateMessage('检测到新版本,正在下载……')
})
autoUpdater.on('update-not-available', function (info) {
sendUpdateMessage('现在使用的就是最新版本,不用更新')
})
// 更新下载进度事件 ***** 系统先是 update-available 检测到新版本 **** download-progress 这里没有执行就停止了
autoUpdater.on('download-progress', function (progressObj) {
console.log("download-progress----------------------------")
mainWindow.webContents.send('downloadProgress', progressObj)
})
// 下载完成
autoUpdater.on('update-downloaded', function (event, releaseNotes, releaseName, releaseDate, updateUrl, quitAndUpdate) {
ipcMain.on('isUpdateNow', (e, arg) => {
autoUpdater.quitAndInstall()
});
mainWindow.webContents.send('----- 开始更新 isUpdateNow----')
});
ipcMain.on("checkForUpdate",()=>{ //执行自动更新检查
console.log("执行自动更新检查checked~~~")
autoUpdater.checkForUpdates()
})
}
// 通过main进程发送事件给renderer进程,提示更新信息.
function sendUpdateMessage(text) {
mainWindow.webContents.send('message', text)
}
publish 也配置好了
"publish": [
{
"provider": "generic",
"url": "http://127.0.0.1:5000/download/"
}
]
]