在非默认浏览器中使用 Electron 打开 URL

Ari*_*501 2 javascript google-chrome cross-browser electron microsoft-edge

我正在使用 Electron 尝试打开 URL。我知道我可以做类似的事情

const { shell } = require('electron')

shell.openExternal('https://github.com')
Run Code Online (Sandbox Code Playgroud)

在默认浏览器中打开 URL。

有没有办法在非默认浏览器中执行此操作?例如,如果我想打开指向 Edge Store 的链接,但我的默认浏览器是 Chrome,我可以执行以下操作吗

const { shell } = require('electron')

shell.openExternal('microsoft-edge:https://github.com')
Run Code Online (Sandbox Code Playgroud)

Dec*_*ree 5

仅使用 default 是无法做到这一点的shell,因为据我所知,它完全依赖于用户系统默认值,但是现有的 npm 包(例如open )将为您提供此功能,例如:

await open('microsoft-edge:https://github.com');

他们的文档将引导您完成如何使其正常工作。