这些天我玩弄Electronbuild立一个小的本地应用程序的Windows,我正在使用Grunt电子安装程序为我的应用程序创build一个安装程序。
安装程序创build成功,但我不知道如何处理我的应用程序内松鼠的事件,正如我已经添加到我的应用程序的入口点的文档中所述:
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; }
但是我不知道在switch语句里面要做什么,例如为我的应用程序创build快捷方式。 其实我什至不知道这个开关是否工作,因为当我安装(或卸载)我的应用程序,它启动,永不退出。
任何帮助表示赞赏!
你可以处理每个松鼠事件,并创建快捷方式:
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;