Electron将Node.js和Chromium上下文结合起来意味着什么? [英] What does it mean for Electron to combine Node.js and Chromium contexts?

查看:488
本文介绍了Electron将Node.js和Chromium上下文结合起来意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

博客文章中,作者提到Electron将Node和Chromium合并为单一内容上下文这意味着我们不必使用Browserify来转换代码。

In a blog post the author mentions that Electron combines Node and Chromium into a "single context" which implies that we don't have to use Browserify to transform code.

我理解Electron的一个含义是您可以使用Web构建跨平台的桌面应用程序技术。我也理解为什么我们能够写入文件系统的原因是因为Electron已经将Node编入其中。而且,我们能够使用HTML / CSS / JS / DevTools的原因是因为Chromium被烘焙了。但是,我不要认为这是作者所说的。

I understand that one implication of Electron is you can build cross-platform desktop apps using web technologies. I also understand the reason why we're able to write to the filesystem is because Electron has Node baked in. Also, the reason we're able to use HTML/CSS/JS/DevTools is because Chromium is baked in. However, I don't think this is what the author is talking about.


  • Electron如何将Node和Chromium组合成单一背景?

  • 为什么不再使用Browserify?

推荐答案

Chromium 是一个基于Webkit的Web浏览器,带有V8 javascript引擎。它支持所有常用的浏览器和DOM API,因此适用于制作网页而不擅长与底层系统交互。

Chromium is a Webkit based web browser with the V8 javascript engine. It supports all the usual browser and DOM APIs and thus is good for making web pages and not good at interacting with the underlying system.

Node.js 是通过去除V8引擎,制作无头命令行应用程序,并添加大量API来访问文件系统来构建的, require()其他文件,运行其他shell程序等(你对真正的脚本语言的期望。

Node.js was built by striping out the V8 engine, making a headless command line application, and adding extensive APIs to access the file system, require() other files, run other shell programs, etc. (things you'd expect of a true scripting language.

电子以简化的方式试图取代V8 Chromium中使用的引擎具有Node.js中新的更通用的方法。它向node.js公开了一些额外的API以允许打开铬窗口,但是每个铬窗口都使用< script> ;
标签将使用node.js引擎解释它。

Electron in a simplified way is an attempt to replace the V8 engine used in Chromium with the new more general purpose oriented one of Node.js. It exposes a few extra APIs to node.js to allow for opening chromium windows, but also every chromium window using a <script> tag will interpret it with the node.js engine.

为何选择电子?原因Chromium本身不能做到这一点是因为它最初被设计为Web浏览器和Web浏览器文件系统API是闻所未闻的,因为通常文件托管在远程服务器上,访问用户计算机上的文件会带来安全风险(因为为什么任何一个网页都可以访问所有文件?)。

Why Electron? The reason that Chromium can't do this by itself is because it was originally designed to be a web browser and in web browsers file system APIs would be unheard of as typically files are hosted on a remote server and accessing files on a user's computer would be a security risk (because why should any single webpage have access to all your files?).

require 语句现在开箱即用,因为node.js具有文件系统支持将允许它们从磁盘同步读取而无需将它们捆绑到同一个javascript文件中或从服务器请求它们。

require statements now work out of the box because node.js has filesystem support will allows them to be synchronously read from the disk without the need for bundling them into the same javascript file or requesting them from a server.

这篇关于Electron将Node.js和Chromium上下文结合起来意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆