我正在尝试使用电子生成器的自动更新功能,我已经为update-not-available和update-available添加了侦听器。如果没有新的更新,update-not-available事件将被成功触发,但由于某种原因,当我的应用程序的新版本可用时,update-available事件没有被触发,有没有办法检查为什么没有触发该事件,或者添加日志以查看是否发生了错误?下面是我的main.js代码
const { autoUpdater } = require("electron-updater");
...other imports
app.on('ready', () => {
//do this
//Check for updates.
autoUpdater.checkForUpdates();
}
autoUpdater.on("update-not-available", (info) => {
const dialogOpts = {
type: 'info',
buttons: ['Ok'],
title: 'Application Update',
message: "Yay",
detail: 'No new updates.'
}
dialog.showMessageBox(dialogOpts, (response) => {
});
});
autoUpdater.on("update-available", (info) => {
const dialogOpts = {
type: 'info',
buttons: ['Ok'],
title: 'Application Update',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'A new version is being downloaded.'
}
dialog.showMessageBox(dialogOpts, (response) => {
});
})
autoUpdater.on("update-downloaded", (info) => {
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()
});
});发布于 2018-03-16 11:14:17
通过从命令行运行可执行文件,我能够得到失败的原因。因为下面的线,它失败了。
message: process.platform === 'win32' ? releaseNotes : releaseName,因为变量是未定义的。通过将回调函数参数更改为包含releaseName和releaseNotes (类似于
autoUpdater.on("update-available", (event, releaseNotes, releaseName) => {正如docs 这里中所提供的那样。
https://stackoverflow.com/questions/49316963
复制相似问题