在整页加载中,检测是否为电子

Pla*_*mer 3 javascript node.js electron

在我的应用中,我需要满负荷运行,检测是否为Electron,然后触发自定义事件。如何实现呢?提前致谢。

www*_*.me 5

我喜欢这个

// check if app is running inside the electron env or browser
var userAgent = navigator.userAgent.toLowerCase();
if (userAgent.indexOf(' electron/') == -1) {
  // its not electron
}
Run Code Online (Sandbox Code Playgroud)