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/"
      }
    ]
]
                    
                    
                2 回答
                            一只名叫tom的猫
                            
                                
                            
                        
                        
                                                
                    TA贡献1906条经验 获得超3个赞
已经找到问题的原因,不支持electron 3.0以下的版本, 在网上看到的都是降低版本,什么版本号配什么,最后就发现 只需要把electron 升级了就可以了,还发觉一个问题,打包的文件不能是中文
添加回答
举报
0/150
	提交
		取消
	