如何在Electron内正确运行Rails应用程序? [英] How to properly run a Rails app inside Electron?
问题描述
我对Electron还是很陌生,只是尝试遵循文档.
我能够在Electron中运行html,并且效果很好.
I am very new to Electron, just tried to follow the Documentation.
I was able to run a html in Electron and it worked fine.
然后,我尝试使用BrowserWindow loadUrl加载Rails应用程序,但是该应用程序的javascript在Electron内部无法正常工作.
Then I tried to load a Rails app with BrowserWindow loadUrl, but the javascripts of the app are not working inside Electron.
我的主要是这里的index.js:
My main is this index.js here:
var app = require ('app')
var BrowserWindow = require ('browser-window')
app.on('ready', function(){
var mainWindow = new BrowserWindow({
width:1115,
height:945
})
mainWindow.loadUrl('http://my-app-at-heroku.herokuapp.com')
})
在我的计算机上运行服务器并加载 http://localhost:3000 具有相同的行为.该应用程序出现了,但是js无法正常工作.
Running the server in my machine and loading http://localhost:3000 has the same behavior. The app appears, but the js don't work.
我错过了什么?如何在Electron内正确运行Rails应用程序?
What have I missed? How do I properly run a Rails app inside Electron?
推荐答案
供以后参考,解决此问题的正确方法是将BrowserWindow上的"node-integration"
选项设置为false
,如下所示:
For future reference, the correct way to solve this is to set the "node-integration"
option on BrowserWindow to false
, like so:
var app = require ('app')
var BrowserWindow = require ('browser-window')
app.on('ready', function(){
var mainWindow = new BrowserWindow({
width:1115,
height:945,
"node-integration": false
})
mainWindow.loadUrl('http://my-app-at-heroku.herokuapp.com')
})
来源: https://github.com/atom/electron/issues/254#issuecomment-82322963
这篇关于如何在Electron内正确运行Rails应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!