electron使用代理
Last week we announced the release of Rodeo v1.0. The big deal was that we’d taken Rodeo from a command line, python app built using Flask, to a more legitimate looking desktop app.
上周,我们宣布发布了Rodeo v1.0 。 重要的是,我们将Rodeo从命令行(使用Flask构建的python应用程序)转移到了外观更合理的桌面应用程序中。
There were comments on reddit and twitter mentioning that it seemed like Rodeo was running it’s own browser behind the scenes–and these comments were 100% correct! That’s because Rodeo 1.0 is built with Electron, a cross-platform framework for building desktop apps with good ‘ole javascript and HTML. (check out the code on GitHub)
关于reddit和twitter的评论中提到Rodeo似乎在幕后运行它自己的浏览器-这些评论是100%正确的! 那是因为Rodeo 1.0是用Electron构建的, Electron是一个跨平台框架,用于构建具有出色的ole javascript和HTML的桌面应用程序。 ( 在GitHub上查看代码 )
To put it simply, you can build great looking windows and osx applications without mastering C# or Objective-C…with a single codebase. Sounds pretty nice, right? Want to learn more about how we did it? Keep reading!
简而言之,您可以构建美观的Windows和osx应用程序,而无需使用单个代码库掌握C#或Objective-C。 听起来不错,对吗? 想更多地了解我们是如何做到的? 继续阅读!
Our latest creation, Rodeo, is built with Electron.
我们的最新作品Rodeo是用Electron构建的。
将Rodeo带到桌面 (Taking Rodeo to the desktop)
The first version of Rodeo ran as a Flask web app with a command line client. This worked well enough, but we found that by requiring Rodeo to be used via the command line, we were instantly decreasing our addressable user-base. Not so surprising.
Rodeo的第一个版本作为带有命令行客户端的Flask Web应用程序运行。 这足够有效,但是我们发现通过要求通过命令行使用Rodeo,我们立即减少了可寻址的用户群。 并不奇怪。
As a result, we decided that we needed a desktop version of Rodeo.
结果,我们决定需要台式版的Rodeo。
对电子说“你好” (Say “Hello” to Electron)
We really didn’t want to get into the business of building a native app– especially since our users are split fairly evenly between Mac and Windows. This led us to Electron. Electron really fit the bill:
我们真的不想从事构建本机应用程序的业务-特别是因为我们的用户在Mac和Windows之间平均分配。 这导致了我们到电子 。 Electron非常适合:
- ✓ ships with windows and mac installers
- ✓ runs on the desktop
- ✓ no OS specific code required
- ✓Windows和Mac安装程序附带
- ✓在桌面上运行
- ✓无需特定于操作系统的代码
But the real kicker is that you can write your entire application using node.js! For Rodeo, this meant that 80% of the code from the Flask app was reusable.
但是真正的缺点是您可以使用node.js编写整个应用程序 ! 对于Rodeo而言,这意味着Flask应用程序中80%的代码是可重用的。
Under the hood, it’s our old friends HTML, CSS, and Javascript.
在后台,这是我们的老朋友HTML,CSS和Javascript。
电子做什么 (What Electron does)
Aside from distribution, Electron is doing some pretty nifty stuff. By far my favorite thing it does is that it binds node.js to the native UI. You can use things like windows, file dialogs, and Finder/Explorer all from the comfort of javascript.
除了发行外,Electron还在做一些漂亮的事情。 到目前为止,我最喜欢做的是将node.js绑定到本机UI。 您可以使用javascript轻松使用诸如windows , 文件对话框和Finder / Explorer之类的东西。
In addition to native UI components, Electron acts as your “server”. In actuality it’s a Chromium window with some magic fairy dust sprinkled on top of it. It has built in support for websocket-esque messages (ipc
) so it feels a lot like building a “regular” app.
除了本机UI组件之外,Electron还充当您的“服务器”。 实际上,这是一个Chromium窗口,上面洒了一些神奇的仙尘。 它内置了对websocket式消息( ipc
)的支持,因此感觉很像构建“常规”应用程序。
Lastly, and possibly most importantly, you can use node modules from within your “front-end”. So for example, if you’re adding an DOM event that will create a file, you can just use fs.writeFile
instead of having to make an AJAX request to your server. In other words, you’re going to write a lot less code, and accomplish just as much!
最后,也是最重要的一点,您可以在“前端”中使用节点模块。 因此,例如,如果要添加将创建文件的DOM事件,则可以仅使用fs.writeFile
而不必向服务器发出AJAX请求。 换句话说,您将编写更少的代码,并完成尽可能多的工作!
Do more by doing less.
事半功倍。
精美易用的套件 (Great, easy to use packages)
Another great part about Electron, without a doubt, is the packages that come with it. Even though it’s a relatively new project, there are already some very helpful 3rd party libraries. For instance, we’re using electron-packager to distribute OS specific executables, electron-builder to build OS specific installers, and Nuts for distribution/download management.
毫无疑问,Electron的另一个重要方面是它附带的包装。 即使这是一个相对较新的项目,也已经有一些非常有用的第三方库。 举例来说,我们使用电子打包分发操作系统特定的可执行文件, 电子制造商打造的操作系统特定的安装,以及坚果分发/下载管理。
There are tons of other great resources for getting started.
还有大量其他大量的入门资源 。
We’re using electron-builder to build windows and osx installers.
我们正在使用电子构建器来构建Windows和osx安装程序。
整理起来 (Finishing up)
翻译自: https://www.pybloggers.com/2015/10/how-we-built-rodeo-with-electron/
electron使用代理