首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >寻找有关更新已安装的电子应用程序的过程的完整教程

寻找有关更新已安装的电子应用程序的过程的完整教程
EN

Stack Overflow用户
提问于 2016-08-04 00:52:39
回答 1查看 884关注 0票数 0

我读了很多关于这个subjet的东西,但是我找不到一个完整的文档。我成功地使用电子打包器和电子安装程序为我的电子应用程序获得了一个setup.exe。我使用电子发布服务器创建了一个服务器来托管我要部署的电子应用程序。

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

代码语言:javascript
复制
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();
} );

但是当我安装我的应用程序时,我会遇到这样的错误:

事实上,我想我不知道该怎么做客户端,但服务器端也是如此。任何帮助都将不胜感激!提前感谢

EN

回答 1

Stack Overflow用户

发布于 2016-09-07 02:37:49

我在我的版本中使用了以下内容,并且可以正常工作(托盘图标除外):

代码语言:javascript
复制
  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);是真正的变通方法。剩下的只是一个很好的补充,我认为

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38749497

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档