electron-updater#UpdateInfo TypeScript Examples

The following examples show how to use electron-updater#UpdateInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UpdateHandler.ipc.ts    From Bridge with GNU General Public License v3.0 6 votes vote down vote up
private registerUpdaterListeners() {
    autoUpdater.on('error', (err: Error) => {
      updateAvailable = null
      emitIPCEvent('update-error', err)
    })

    autoUpdater.on('update-available', (info: UpdateInfo) => {
      updateAvailable = true
      emitIPCEvent('update-available', info)
    })

    autoUpdater.on('update-not-available', (info: UpdateInfo) => {
      updateAvailable = false
      emitIPCEvent('update-available', null)
    })
  }
Example #2
Source File: updater.ts    From SpaceEye with MIT License 6 votes vote down vote up
/**
 * Prompt the user to see if they want to update the app.
 *
 * @param info - Info about the update
 */
async function promptForUpdate(info: UpdateInfo) {
    // Don't alert the user more than once for an update version
    if (updateAlertVersions[info.version] === true) {
        return
    }
    updateAlertVersions[info.version] = true

    const res = await dialog.showMessageBox({
        type: 'info',
        buttons: ['Restart', 'Later'],
        message: 'Update Ready to Install',
        detail:
            'A new version of SpaceEye is ready to install. Restart application to apply the update.',
        defaultId: 0,
        cancelId: 1
    })
    if (res.response === 0) {
        autoUpdater.quitAndInstall()
    }
}
Example #3
Source File: updater.ts    From SpaceEye with MIT License 6 votes vote down vote up
// Handle when an update is downloaded
autoUpdater.on('update-downloaded', (info: UpdateInfo) => {
    isUpdateDownloaded = true
    if (AppConfigStore.autoUpdate) {
        tryUpdating()
    } else {
        promptForUpdate(info)
    }
})
Example #4
Source File: index.ts    From electron-playground with MIT License 6 votes vote down vote up
private async onUpdateAvailable(info: UpdateInfo) {
    this.log('有可用更新:', info)
    this.setStatus(UpdateStatus.Available)
    this.updateInfo = info
    if (!this.silent) {
      const { response } = await messageBox.info({
        message: '有可用更新',
        detail: this.updateInfoMessage,
        buttons: ['取消', '下载更新'],
      })
      if (response === 1) {
        autoUpdater.downloadUpdate()
      }
    } else {
      autoUpdater.downloadUpdate()
    }
  }
Example #5
Source File: index.ts    From electron-playground with MIT License 6 votes vote down vote up
private async onUpdateNotAvailable(info: UpdateInfo) {
    this.log('无可用更新', info)
    if (!this.silent) {
      await messageBox.info({
        message: '无可用更新',
      })
    }
    this.setStatus(UpdateStatus.Idle)
  }
Example #6
Source File: index.ts    From electron-playground with MIT License 6 votes vote down vote up
private async onUpdateDownloaded(info: UpdateInfo) {
    this.log('下载完成', info)
    if (!this.silent) {
      const { response } = await messageBox.info({
        message: '下载完成, 立即更新?',
        detail: this.updateInfoMessage,
        buttons: ['取消', '确定'],
      })
      if (response === 0) {
        this.setStatus(UpdateStatus.Ready)
        return
      }
      if (response === 1) {
        autoUpdater.quitAndInstall()
        // 如果updater退出不成功,手动调用退出
        setTimeout(() => {
          app.quit()
        }, 500)
        return
      }
    }
    this.setStatus(UpdateStatus.Ready)
  }
Example #7
Source File: index.ts    From electron-playground with MIT License 5 votes vote down vote up
/**
   * 用户手动检查
   * 手动检查时可能由于此时处于静默更新过程中,所以会存在多种状态,不能直接去调起自动检查更新就完事,需要针对不同状态给用户不同提示
   */
  public async manualCheck() {
    this.silent = false
    switch (this.status) {
      case UpdateStatus.Idle:
        this.silent = false
        autoUpdater.checkForUpdates()
        break
      case UpdateStatus.Checking:
        this.silent = false
        break
      case UpdateStatus.Available:
        this.silent = false
        this.onUpdateAvailable(this.updateInfo as UpdateInfo)
        break
      case UpdateStatus.Downloading:
        messageBox.info({
          message: '有可用更新,下载中...',
          detail: `${this.updateInfoMessage}
          ad
          asd
          `,
        })
        break
      // case UpdateStatus.Updating:
      case UpdateStatus.Downloaded:
      case UpdateStatus.Ready:
        const { response } = await messageBox.info({
          message: '有可用更新,已下载完成,是否立即更新?',
          detail: this.updateInfoMessage,
          buttons: ['取消', '确定'],
        })
        if (response === 1) {
          autoUpdater.quitAndInstall()
        }
        break
      default:
        break
    }
    return this.status
  }
Example #8
Source File: index.ts    From electron-playground with MIT License 5 votes vote down vote up
private updateInfo: UpdateInfo | null = null