电子更新可用和更新下载的事件不会在客户端激活

时间:2017-09-21 06:31:40

标签: electron auto-update

当客户端调用autoUpdater.checkForUpdates()时,我可以看到服务器日志显示:

  

debug:Windows Update搜索查询{         平台:['windows_32'],         版本:'2.0.0',         频道:'稳定'       }       debug:适用的频道['stable'] debug:Time Filter {         '> =':2017 - 09 - 20 T08:43:10.000 Z.       }       debug:最新的Windows版本{         资产:[{           名称:'DesktopAlert-3.0.0-ia32-full.nupkg',           平台:'windows_32',           filetype:'。nupkg',           哈希:'3536C0AD153B97027FEDE24CE1E9FE6C9863E04B',           大小:52623567,           download_count:0,           fd:'C:\ Projects \ electron-release-server \ data \ 34506780-7e2c-487e-9bb6-67b47674e76b.nupkg',           createdAt:'2017-09-20T09:11:09.000Z',           updatedAt:'2017-09-20T09:11:09.000Z',           版本:'3.0.0'         }],         频道:'稳定',         名称:'3.0.0',         笔记:'',         createdAt:'2017-09-20T08:43:31.000Z',         更新时间:'2017-09-20T08:43:31.000Z'       }

但在客户端上,没有事件被触发。 这是自动更新的客户端代码

autoUpdater.on('update-not-available', (event, releaseNotes, releaseName) => {
  console.log(event)
  mainWindow.webContents.send('update-not-available', {
    msg: event
  })
})

autoUpdater.on('update-available', (event, releaseNotes, releaseName) => {
  console.log(event)
  mainWindow.webContents.send('update', {
    msg: event
  })
})
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
  console.log(event)
  mainWindow.webContents.send('downloaded', {
    msg: event
  })
  const dialogOpts = {
    type: 'info',
    buttons: ['Restart', 'Later'],
    title: 'Application Update',
    message: process.platform === 'win32' ? releaseNotes : releaseName,
    detail: 'A new version has been downloaded. Restart the application to apply the updates.'
  }
  dialog.showMessageBox(dialogOpts, (response) => {
    if (response === 0) autoUpdater.quitAndInstall()
  })
})

autoUpdater.on('checking-for-update', (event, releaseNotes, releaseName) => {
  console.log(event)
  mainWindow.webContents.send('checking', {
    msg: event
  })
})

autoUpdater.on('error', message => {
  console.error('There was a problem updating the application')
  console.error(message)
})

请帮助,我忘了什么吗? P / s:对不起代码格式,不知道如何把代码引用

0 个答案:

没有答案