我正在我的 Electron 应用程序中加载远程站点。我想在 Electron 壳中添加一些自定义 CSS。我注意到 package.json 中的名称出现在 UserAgent 中。我知道我可以执行以下操作:
if(navigator.userAgent.indexOf('MyApp') >= 0) document.body.classList.add('electronified');
我想知道这是否是最好的方法?或者我是否应该从主流程中执行此操作。你有什么想法?
最佳答案
我认为你应该尝试查看 process.versions.electron
。
if (process && process.versions && process.versions.electron) {
document.body.classList.add('electronified');
}
这是假设您没有在 <webview>
内运行您的应用程序当然。
关于electron - 最佳实践 : Detecting electron shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33422680/