Manifestez l’événement de Squirrel sur une application Electron

Aujourd’hui, je travaille avec Electron pour créer une petite application native pour Windows et j’utilise Grunt Electron Installer pour créer un programme d’installation pour mon application.

Le programme d’installation est créé avec succès mais je ne sais pas comment gérer les événements de Squirrel dans mon application, comme indiqué dans les documents que j’ai ajoutés au point d’entrée de mon application:

var handleStartupEvent = function() { if (process.platform !== 'win32') { return false; } var squirrelCommand = process.argv[1]; switch (squirrelCommand) { case '--squirrel-install': case '--squirrel-updated': // Optionally do things such as: // // - Install desktop and start menu shortcuts // - Add your .exe to the PATH // - Write to the registry for things like file associations and // explorer context menus // Always quit when done app.quit(); return true; case '--squirrel-uninstall': // Undo anything you did in the --squirrel-install and // --squirrel-updated handlers // Always quit when done app.quit(); return true; case '--squirrel-obsolete': // This is called on the outgoing version of your app before // we update to the new version - it's the opposite of // --squirrel-updated app.quit(); return true; } }; if (handleStartupEvent()) { return; } 

Mais je ne sais pas quoi faire dans cette instruction de commutateur pour, par exemple, créer des raccourcis pour mon application. En fait, je ne sais même pas si ce commutateur fonctionne du tout parce que lorsque j’installe (ou désinstalle) mon application, elle est lancée et ne se ferme jamais.

Toute aide est appréciée!

Vous pouvez gérer chaque événement Squirrel et créer des raccourcis:

  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;