在electron.js中如何解决“跳过应用程序未打包的Skip checkForUpdatesAndNotify”

问题描述 投票:7回答:1

我正在使用“电子更新程序”来检查电子应用程序的自动更新。

调用“ checkForUpdatesAndNotify()”函数。

在控制台中,我收到“跳过checkForUpdatesAndNotify,因为应用程序未打包”。

  • mac0S莫哈韦沙漠,
  • “电子更新程序:” ^ 4.0.6“,
  • “电子”:“ ^ 3.0.13”,
  • “电子生成器”:“ 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');
        });
    
electron auto-update electron-builder
1个回答
0
投票

[checkForUpdatesAndNotify()只是在开发模式下不起作用。

如果您坚持在开发人员模式下对其进行测试,则可以使用isPackaged进行一些修改:

const app = require('electron').app;

Object.defineProperty(app, 'isPackaged', {
  get() {
    return true;
  }
});

请注意,请勿将本hack用于生产,这可能

© www.soinside.com 2019 - 2024. All rights reserved.