Handle Squirrel's event on an Electron app

前端 未结 1 1181
生来不讨喜
生来不讨喜 2021-01-03 04:06

These days I\'m toyng around with Electron to build a small native app for Windows and I\'m using Grunt Electron Installer to create an installer for my application.

相关标签:
1条回答
  • 2021-01-03 04:44

    You could handle each Squirrel event and create shortcuts:

      case '--squirrel-install':
              target = path.basename(process.execPath);
              updateDotExe = path.resolve(path.dirname(process.execPath), '..', 'update.exe');
              var createShortcut = updateDotExe + ' --createShortcut=' + target + ' --shortcut-locations=Desktop,StartMenu' ;
              console.log (createShortcut);
              exec(createShortcut);
              // Always quit when done
              app.quit();
              return true;
    
    case '--squirrel-uninstall':
                // Undo anything you did in the --squirrel-install and
                // --squirrel-updated handlers
                target = path.basename(process.execPath);
                updateDotExe = path.resolve(path.dirname(process.execPath), '..', 'update.exe');
                var createShortcut = updateDotExe + ' --removeShortcut=' + target ;
                console.log (createShortcut);
                exec(createShortcut);
                // Always quit when done
                app.quit();
                return true;

    0 讨论(0)
提交回复
热议问题