电子URL方案"open-url"事件 [英] electron url scheme "open-url" event

查看:152
本文介绍了电子URL方案"open-url"事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在index.js中执行了以下操作;

I did the following in my index.js;

electron.remote.app.on("open-url", function(event, url) {
  console.log("Open URL: " + url);
});

这在Mac OS中触发,但在Windows中不触发.在Windows中还有其他事件或其他方式可以做到吗?

This gets triggered in Mac OS, but not in Windows. Is there another event or a different way to do it in windows?

推荐答案

这是仅限Mac的功能. 最接近的替代方法是 app.makeSingleInstance(callback).

This is a mac-only feature. The closest alternative is app.makeSingleInstance(callback).

您可以安排使用url作为参数启动应用程序:myApp my-scheme://stuff

You can arrange for your app to be launched with the url as argument: myApp my-scheme://stuff

然后,无论首先启动哪个应用程序进程,都使用URL调用callback.

Then callback is called with the url in whichever app process was launched first.

这篇关于电子URL方案"open-url"事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆