windows – 在Electron应用程序上处理Squirrel的活动
发布时间:2020-12-13 20:41:46 所属栏目:Windows 来源:网络整理
导读:这些天我用 Electron来为Windows构建一个小的本机应用程序,我正在使用 Grunt Electron Installer为我的应用程序创建一个安装程序. 安装程序已成功创建,但我不知道如何在我的应用程序中处理Squirrel的事件,如我在应用程序的入口点添加此文档中所述: var hand
这些天我用
Electron来为Windows构建一个小的本机应用程序,我正在使用
Grunt Electron Installer为我的应用程序创建一个安装程序.
安装程序已成功创建,但我不知道如何在我的应用程序中处理Squirrel的事件,如我在应用程序的入口点添加此文档中所述: 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语句中要做什么,例如,为我的应用程序创建快捷方式.实际上我甚至不知道这个开关是否有效,因为当我安装(或卸载)我的应用程序时它会启动并且永不退出. 任何帮助表示赞赏!
您可以处理每个Squirrel事件并创建快捷方式:
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; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows phone 8:从代码中打开app中的facebook页面
- 当通过LoadLibrary调用DLL时,MFC状态无效
- 我应该用什么来替换Windows上的gettimeofday()?
- Windows 下单机最大TCP连接数
- Windows – 如何在一个窗口中运行多个进程的Delphi中创建Ch
- windows环境下memcache相关配置及PHP加载相应模块(php7版本
- windows – ruby?? win32api&structs(VerQueryValue)
- OS X:无法解析Windows计算机名称
- Windows驱动器号A:和B:
- 安装程序 – 安装项目不替换程序集文件
推荐文章
站长推荐
- windows-server-2008 – FTP服务器的建议,允许限
- 计算机的日常维护--制作并使用xit
- windows-server-2003 – 服务器实际需要多少RAM?
- windows-server-2008 – 是否有正确的方法在Wind
- windows-phone-7 – 在tombstone之后恢复LongLis
- windows-phone-7 – 访问Windows Phone中未接来电
- Wix安装程序问题:为什么RestartManager将服务标
- windows-server-2003 – PerfMon计数器不可用
- windows-phone-7 – Windows Phone:确定设备(制
- windows下安装linux(ubuntu)系统
热点阅读