的想法:
当新版本发布时,electron-updater应该自动更新我的electron软件。
问题: electron-updater检测新版本,但不下载并安装它。我使用electron-updater@4.3.8并使用electron-builder@8.17.0构建我的应用程序。
不幸的是,改用旧版本也于事无补。
更新:
电子现在抛出错误autoUpdater.autoDownload is not a function。
代码片段
Main.js:
// 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:
{
"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
发布于 2022-08-17 09:24:56
删除autoUpdater.autoDownload()修复了autoUpdater.autoDownload is not a function错误。
另一个错误(更新没有下载)是与我的GitHub相关的。在那里,.exe文件的命名与.exe.blockmap文件不同,这就是电子更新程序返回404错误的原因。
https://stackoverflow.com/questions/73374776
复制相似问题