首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >电子更新程序检测更新,但不下载更新。

电子更新程序检测更新,但不下载更新。
EN

Stack Overflow用户
提问于 2022-08-16 13:26:46
回答 1查看 353关注 0票数 0

的想法:

当新版本发布时,electron-updater应该自动更新我的electron软件。

问题: electron-updater检测新版本,但不下载并安装它。我使用electron-updater@4.3.8并使用electron-builder@8.17.0构建我的应用程序。

不幸的是,改用旧版本也于事无补。

更新

电子现在抛出错误autoUpdater.autoDownload is not a function

代码片段

Main.js:

代码语言:javascript
复制
    // autoUpdater.checkForUpdatesAndNotify() is called in "mainWindow.on('ready-to-show', ...)

    // ------ AutoUpdater ------ //
    autoUpdater.logger = log;
    autoUpdater.logger.transports.file.level = 'info';

    const sendStatusToWindow = (text) => {
      log.info(text);
      if (mainWindow) {
        mainWindow.webContents.send('update', text)
      }
    }

    autoUpdater.on('checking-for-update', () => {
      sendStatusToWindow('Checking for update...')
    })

    autoUpdater.on('update-available', (info) => {
      sendStatusToWindow('Update available.')
      autoUpdater.autoDownload()
    })

    autoUpdater.on('update-not-available', (info) => {
      sendStatusToWindow('Update not available.')
    })

    autoUpdater.on('error', (err) => {
      log.error(`Update-Error: ${err.toString()}`)
      mainWindow.webContents.send('message', `Error in auto-updater: ${err.toString()}`)
    })

    autoUpdater.on('download-progress', progressObj => {
      sendStatusToWindow(
        `Download speed: ${progressObj.bytesPerSecond} - Downloaded ${progressObj.percent}% (${progressObj.transferred} + '/' + ${progressObj.total} + )`
      )
    })

    autoUpdater.on('update-downloaded', () => {
      sendStatusToWindow('Update downloaded; will install now')
      autoUpdater.quitAndInstall();
    })

Package.json:

代码语言:javascript
复制
    {
      "name": "iac_2",
      "productName": "IAC 2.0",
      "version": "0.8.3-alpha",
      "homepage": "https://github.com/JueK3y/Instagram-automated-commenting",
      "repository": {
        "type": "git",
        "url": "https://github.com/JueK3y/Instagram-automated-commenting"
      },
      "main": "main.js",
      "scripts": {
        "start": "electron .",
        "test": "echo \"Error: no test specified\" && exit 1",
        "pack": "electron-builder --dir",
        "dist": "electron-builder"
      },
      "devDependencies": {
        "electron": "^15.5.7"
      },
      "dependencies": {
        "electron-log": "^4.4.8",
        "electron-updater": "^4.3.8",
        "electron-window-state": "^5.0.3",
        "is-online": "^9.0.1",
        "keytar": "^7.9.0",
        "network-speed": "^2.1.1",
        "node-notifier": "^10.0.1",
        "puppeteer": "^16.0.0",
        "puppeteer-extra": "^3.3.4",
        "puppeteer-extra-plugin-stealth": "^2.11.0"
      },
      "build": {
        "appId": "jue3ky.iac_2.app",
        "productName": "IAC 2.0",
        "copyright": "Copyright © 2022 by JueK3y",
        "win": {
          "target": "nsis",
          "icon": "icon.ico",
          "publish": {
            "provider": "github"
          }
        },
        "asar": true,
        "asarUnpack": "node_modules/puppeteer/.local-chromium/**/*"
      }
    }

完整代码在这里:https://github.com/JueK3y/Instagram-automated-commenting/tree/main/public

EN

回答 1

Stack Overflow用户

发布于 2022-08-17 09:24:56

删除autoUpdater.autoDownload()修复了autoUpdater.autoDownload is not a function错误。

另一个错误(更新没有下载)是与我的GitHub相关的。在那里,.exe文件的命名与.exe.blockmap文件不同,这就是电子更新程序返回404错误的原因。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73374776

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档