【问题标题】:Making desktop installers for apps?为应用程序制作桌面安装程序?
【发布时间】:2015-11-09 09:08:54
【问题描述】:

我使用 electron 已经有一段时间了,并且已经构建了几个应用程序,但还没有弄清楚如何创建桌面图标和 windows 安装程序(在电子主页上,它特别说制作 windows 安装程序是“制造容易”。)

我将如何为典型的电子设置中的应用程序制作这样的 Windows 安装程序,以及自动安装桌面图标(GNOME 为 .desktop,Windows 快捷方式)?

我知道这似乎是一个愚蠢的问题,但我就是无法理解不太具体的说明(例如 http://electron.atom.io/docs/v0.34.0/tutorial/application-distribution/ 有点帮助但太模糊了。)

【问题讨论】:

    标签: node.js electron


    【解决方案1】:

    我之前做过一些研究,发现,嗯,创建一个windows安装程序并不容易。

    1. 使用 grunt-electron-installer 创建 Windows 安装程序。请注意,它只会在安装时显示 gif。没有交互式对话框。它使用Squirrel.Windows

    2. 使用Update.exe --createShortcut=<comma separated locations> <your exe> 创建快捷方式。可用位置包括DesktopStartMenuStartupAppRoot

      Update.exe 将在您安装时与您的应用一起提供。我发现this article 很有帮助。简而言之,你需要这样的东西:

      var app = require('app');
      var path = require('path');
      var cp = require('child_process');
      
      var handleSquirrelEvent = function() {
         if (process.platform != 'win32') {
            return false;
         }
      
         function executeSquirrelCommand(args, done) {
            var updateDotExe = path.resolve(path.dirname(process.execPath), 
               '..', 'update.exe');
            var child = cp.spawn(updateDotExe, args, { detached: true });
            child.on('close', function(code) {
               done();
            });
         };
      
         function install(done) {
            var target = path.basename(process.execPath);
            executeSquirrelCommand(["--createShortcut", target], done);
         };
      
         function uninstall(done) {
            var target = path.basename(process.execPath);
            executeSquirrelCommand(["--removeShortcut", target], done);
         };
      
         var squirrelEvent = process.argv[1];
         switch (squirrelEvent) {
            case '--squirrel-install':
               install(app.quit);
               return true;
            case '--squirrel-updated':
               install(app.quit);
               return true;
            case '--squirrel-obsolete':
               app.quit();
               return true;
            case '--squirrel-uninstall':
               uninstall(app.quit);
               return true;
         }
      
         return false;
      };
      
      if (handleSquirrelEvent()) {
         return;
      }
      

    请注意,在较新版本的 Electron 中,您可以使用 auto-updater 来处理 Squirrel.Windows 事件,但 API 有点不同,所以我不确定如何正确使用 auto-updater

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多