【问题标题】:Looking for a complete tutorial about process to update an electron app installed寻找有关更新已安装电子应用程序的过程的完整教程
【发布时间】:2016-09-07 02:37:48
【问题描述】:

我已经阅读了很多关于这个 subjet 的内容,但我找不到完整的文档。 我成功地使用 electron-packager 和 electron-winstaller 为我的电子应用程序获取 setup.exe。 我使用 electron-release-server 创建了一个服务器来托管要部署的电子应用程序。

我在我的电子应用程序中添加了这段代码

const autoUpdater = electron.autoUpdater;
var feedUrl = 'http://10.61.32.53:1337//download/:' + app.getVersion();
autoUpdater.setFeedURL(feedUrl);
// event handling after download new release
autoUpdater.on('update-downloaded', function (event, releaseNotes,       releaseName, releaseDate, updateUrl, quitAndUpdate) {

// confirm install or not to user
var index = dialog.showMessageBox(mainWindow, {
type: 'info',
buttons: [i18n.__('Restart'), i18n.__('Later')],
title: "Typetalk",
message: i18n.__('The new version has been downloaded. Please restart the application to apply the updates.'),
detail: releaseName + "\n\n" + releaseNotes
});

if (index === 1) {
   return;
}

// restart app, then update will be applied
 quitAndUpdate();
} );

但是当我安装我的应用程序时,我有这个错误:

事实上,我想我不明白客户端应该做什么,但服务器端也是如此。任何帮助将不胜感激! 提前致谢

【问题讨论】:

    标签: electron


    【解决方案1】:

    我在我的版本中使用了以下内容并且有效(托盘图标除外):

      app.on('ready', () => {
        console.warn("Starting Autoupdater")
        console.warn(app.getVersion())
        var feedUrl = 'http://ls-desktop.herokuapp.com/update/' + os.platform() + '/' + app.getVersion() + '/';
        autoUpdater.setFeedURL(feedUrl);
    
        tray = new Tray(__dirname + '/LS.png')
        console.log(__dirname + '/LS.png')
    
        console.log('created');
        autoUpdater.on('checking-for-update', function() {
          tray.displayBalloon({
            title: 'Autoupdater',
            content: 'Checking for Update!'
          })
        });
    
        autoUpdater.on('update-available', function() {
            console.log("update-available");
        });
    
        autoUpdater.on('update-not-available', function() {
          tray.displayBalloon({
            title: 'Autoupdater',
            content: 'No Updates availible!'
          })
        });
    
        autoUpdater.on('update-downloaded', function() {
            console.log(" update-downloaded");
        });
    
        setTimeout(function() {autoUpdater.checkForUpdates()}, 10000);
    
        autoUpdater.on('update-downloaded', function (event, releaseNotes, releaseName, releaseDate, updateUrl, quitAndUpdate) {
    
          var index = dialog.showMessageBox({
            type: 'info',
            buttons: ['Restart', 'Later'],
            title: "Lornsenschule Vertretungsplan",
            message: ('The new version has been downloaded. Please restart the application to apply the updates.'),
            detail: releaseName + "\n\n" + releaseNotes
          });
    
          if (index === 1) {
            return;
          }
    
          quitAndUpdate()
        });
      })
    

    注意setTimeout(function() {autoUpdater.checkForUpdates()}, 10000);,这是我使用的真正解决方法。我认为其余的只是一个不错的补充

    【讨论】:

    • 感谢您的帮助。我还没有尝试,但我会的。
    猜你喜欢
    • 1970-01-01
    • 2022-10-12
    • 1970-01-01
    • 2018-08-16
    • 2019-05-14
    • 2018-04-27
    • 2019-04-09
    • 1970-01-01
    • 2011-08-06
    相关资源
    最近更新 更多