首页 文章

在整页加载时,检测是否是Electron

提问于
浏览
2

在我的应用程序中,我需要满载,检测是否是Electron,然后触发自定义事件 . 怎么实现呢?提前致谢 .

2 回答

  • 0

    我更喜欢这个

    // check if app is running inside the electron env or browser
    var userAgent = navigator.userAgent.toLowerCase();
    if (userAgent.indexOf(' electron/') == -1) {
      // its not electron
    }
    
  • 2
    if(process.versions.electron != 'undefined' && process.versions.electron != null){
        //Custom event
    }
    

    我认为这是最标准的做法 .

相关问题