我正在使用“电子更新程序”来检查电子应用程序的自动更新。
调用“ checkForUpdatesAndNotify()”函数。
在控制台中,我收到“跳过checkForUpdatesAndNotify,因为应用程序未打包”。
“电子生成器”:“ 20.28.1”
const {autoUpdater} = require("electron-updater");
autoUpdater.checkForUpdatesAndNotify();
autoUpdater.on('checking-for-update', () => {
console.log('Checking for update...');
});
autoUpdater.on('update-available', (info) => {
console.log('Update available.');
});
autoUpdater.on('update-not-available', (info) => {
console.log('Update not available.');
});
autoUpdater.on('error', (err) => {
console.log('Error in auto-updater. ' + err);
});
autoUpdater.on('download-progress', (progressObj) => {
let log_message = "Download speed: " + progressObj.bytesPerSecond;
log_message = log_message + ' - Downloaded ' + progressObj.percent + '%';
log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')';
console.log(log_message);
});
autoUpdater.on('update-downloaded', (info) => {
console.log('Update downloaded');
});
[checkForUpdatesAndNotify()
只是在开发模式下不起作用。
如果您坚持在开发人员模式下对其进行测试,则可以使用isPackaged
进行一些修改:
const app = require('electron').app;
Object.defineProperty(app, 'isPackaged', {
get() {
return true;
}
});
请注意,请勿将本hack用于生产,这可能