如何在 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屋!