node.js 是否有用于节点应用程序的独立 gui 模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25897951/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 17:53:14  来源:igfitidea点击:

Is there any standlone gui module for node application

node.jsuser-interface

提问by lnman

I want to build a code editor in nodejs. There is option like using an express server to show editor and to execute code in backend. But that would require a browser. So I am looking for node modules that can provide standalone gui for windows platform.

我想在 nodejs 中构建一个代码编辑器。可以选择使用快速服务器来显示编辑器并在后端执行代码。但这需要浏览器。所以我正在寻找可以为 Windows 平台提供独立 gui 的节点模块。

采纳答案by Jessie A. Morris

There are a couple of different options, depending on how you want to proceed.

有几个不同的选项,具体取决于您要如何进行。

Option 1:

选项1:

Use something like QT or GTK bindings to make a more traditional GUI application. These options generally are just Node bindings to the C/C++ API that GTK and QT expose. See node-qtand yue. Although these seem to not be actively developed.

使用诸如 QT 或 GTK 绑定之类的东西来制作更传统的 GUI 应用程序。这些选项通常只是节点绑定到 GTK 和 QT 公开的 C/C++ API。请参阅node-qtyue。虽然这些似乎没有得到积极开发。

Update:

更新:

You can take a look at NodeGUI: https://github.com/nodegui/nodegui

你可以看看NodeGUI:https: //github.com/nodegui/nodegui

NodeGUI is a javascript library for building cross-platform native desktop applications with JavaScript and CSS like styling. It uses Qt under the hood and works on Mac, Linux and Windows.

NodeGUI 是一个 JavaScript 库,用于使用 JavaScript 和 CSS 等样式构建跨平台本机桌面应用程序。它在底层使用 Qt,可在 Mac、Linux 和 Windows 上运行。

It also has a react based renderer called React NodeGUI which is like React Native but for desktop: https://github.com/nodegui/react-nodegui

它还有一个名为 React NodeGUI 的基于 React 的渲染器,它类似于 React Native,但适用于桌面:https: //github.com/nodegui/react-nodegui

Option 2:

选项 2:

Use a framework that takes HTML, CSS, and Javascript and bundles it into a standalone HTML5 app. There are a bunch of frame works out there that do this. Examples include node-webkitand AppJSamong many others.

使用采用 HTML、CSS 和 Javascript 并将其捆绑到独立 HTML5 应用程序中的框架。有很多框架可以做到这一点。示例包括node-webkitAppJS等。

回答by Maher Fattouh

I recommend using an HTML/JS/CSS Framework

我建议使用 HTML/JS/CSS 框架

Option #1:Electronby GitHub.
Website| GitHub Repo| Releases

选项1:电子通过GitHub上
网站| GitHub 回购| 发布

It's easier than you think

If you can build a website, you can build a desktop app. Electron is a framework for creating native applications with web technologies like JavaScript, HTML, and CSS. It takes care of the hard parts so you can focus on the core of your application.

这比你想象的要容易

如果您可以构建网站,则可以构建桌面应用程序。Electron 是一个框架,用于使用 JavaScript、HTML 和 CSS 等 Web 技术创建本机应用程序。它负责处理困难的部分,因此您可以专注于应用程序的核心。

Option #2:NW.js(previously known as node-webkit).
Website| GitHub Repo| Releases

选项 #2:NW.js(以前称为 node-webkit)。
网站| GitHub 回购| 发布

Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.

直接从 DOM/WebWorker 调用所有 Node.js 模块,并启用一种使用所有 Web 技术编写应用程序的新方法。

Electron and NWJS Pros:

Electron 和 NWJS 的优点:

  • AppJS is officially deprecated

  • Electron is similar to NW.js but newer, more popular and has a bigger community and updates more frequently.I recommend it.

  • NWJS always uses the latest Versions of Chromium and Node while Electron takes more time to catch up.

  • NWJS supports [JavaScript Source Protection][1] by compiling it to V8 native code. Electron does not.

  • NWJS have a Legacy release for Windows XP and Mac OS X 10.6 support.

  • Electron and NWJS both use MIT license.

  • AppJS 正式弃用

  • Electron 与 NW.js 类似,但更新、更流行、拥有更大的社区和更频繁的更新。我推荐它。

  • NWJS 总是使用最新版本的 Chromium 和 Node,而 Electron 需要更多时间才能赶上。

  • NWJS 通过将其编译为 V8 原生代码来支持 [JavaScript 源代码保护][1]。电子没有。

  • NWJS 有一个支持 Windows XP 和 Mac OS X 10.6 的 Legacy 版本。

  • Electron 和 NWJS 都使用 MIT 许可证。

You can compare the contributions to electronwith NW.js

你可以用NW.js比较对电子的贡献



Electron and NWJS Cons:

Electron 和 NWJS 缺点:

  • there is no out-of-the-bag run-time solution currently, so you'll have to ship it with your code (~50MB compressed and +100MB uncompressed) or find a way around it.
  • depending on your app, Electron/NWJS might considered an overkill especially since its startup time is less than ideal, just something to take into account.
  • no native look, you'll have to create your own UI elements using CSS or using some framework.
  • 目前没有现成的运行时解决方案,因此您必须将它与您的代码(约 50MB 压缩和 +100MB 未压缩)一起发送或找到解决方法。
  • 根据您的应用程序,Electron/NWJS 可能被认为是一种矫枉过正,尤其是因为它的启动时间不太理想,只是需要考虑的事情。
  • 没有原生外观,您必须使用 CSS 或某些框架创建自己的 UI 元素。


Option #3:DeskGap.
Website| GitHub Repo| Releases

选项#3:DeskGap
网站| GitHub 回购| 发布

DeskGap is a framework for building cross-platform desktop apps with web technologies (JavaScript, HTML and CSS).

To enable native capabilities while keeping the size down, DeskGap bundles a Node.js runtime and leaves the HTML rendering to the operating system‘s webview.

DeskGap 是一个使用 Web 技术(JavaScript、HTML 和 CSS)构建跨平台桌面应用程序的框架。

为了在保持大小不变​​的同时启用本​​机功能,DeskGap 捆绑了一个 Node.js 运行时并将 HTML 呈现留给操作系统的 web 视图。

  • Lightweight since the webview is provided by the operating system.

  • The API is still quite limited (pretty much a work in progress).

  • Requires new OS versions.

  • 轻量级,因为 webview 是由操作系统提供的。

  • API 仍然非常有限(几乎正在进行中)。

  • 需要新的操作系统版本。

回答by Atul

Apart from the other answers here:

除了这里的其他答案:

You can take a look at NodeGUI: https://github.com/nodegui/nodegui

你可以看看NodeGUIhttps: //github.com/nodegui/nodegui

NodeGUI is a javascript library for building cross-platform native desktop applications with JavaScript and CSS like styling. It uses Qt under the hood and works on Mac, Linux and Windows.

NodeGUI 是一个 JavaScript 库,用于使用 JavaScript 和 CSS 等样式构建跨平台本机桌面应用程序。它在底层使用 Qt,可在 Mac、Linux 和 Windows 上运行。

It also has a react based renderer called React NodeGUIwhich is like React Native but for desktop: https://github.com/nodegui/react-nodegui

它还有一个名为React NodeGUI 的基于React的渲染器,它类似于 React Native,但适用于桌面:https: //github.com/nodegui/react-nodegui

Also, its under active development.

此外,它正在积极发展。

回答by Sudhakar RS

Answer specific to your question may be NodeGui(powered by Qt5, NodeGui-React)

特定于您的问题的答案可能是NodeGui(由 Qt5、NodeGui-React 提供支持)

There are many other options. I'm listing a few options below,

还有许多其他选择。我在下面列出了几个选项,

  • electron (Lets you write cross-platform desktop applications using JavaScript, HTML and CSS, based on Node.js & Chromium)
  • carlo (Requires Node & Google Chrome to be installed on the system to run)
  • NW.js (Similar to electron, provides Source code protection)
  • DeskGap (bundles a Node.js runtime and leaves the HTML rendering to the operating system‘s webview)
  • Proton Native (does the same to desktop that React Native did to mobile, based on https://github.com/parro-it/libui-node)
  • 电子(让您使用 JavaScript、HTML 和 CSS 编写跨平台桌面应用程序,基于 Node.js 和 Chromium)
  • carlo(需要在系统上安装 Node 和 Google Chrome 才能运行)
  • NW.js(类似于电子,提供源代码保护)
  • DeskGap(捆绑一个 Node.js 运行时并将 HTML 渲染留给操作系统的 webview)
  • Proton Native(基于https://github.com/parro-it/libui-node对桌面执行与 React Native 对移动执行相同的操作)

For more, you can use my github repo electron-alternativesto pick a cross-platform desktop development option.

有关更多信息,您可以使用我的 github repo电子替代品来选择跨平台桌面开发选项。

回答by cancerbero

I recently discovered https://github.com/yue/yueand I'm having nice experience. It's lightweight, has descent packaging support (and even react/JSX support) and is truly native with decent webview, portable and easy to build target platform's.

我最近发现了https://github.com/yue/yue并且我有很好的体验。它是轻量级的,具有后裔打包支持(甚至 react/JSX 支持),并且是真正原生的,具有不错的 webview,可移植且易于构建目标平台。

Although it seems discontinued I found this project unique, it's really native with options to add a descent webview. I retake some PRs and forked it and I'm adding TypeScript types and documentation since it's really clean/straight forward API, easy to build target platform files. this is my fork although I would like/searching for other users adding missing parts: https://github.com/cancerberoSgx/node-gui. The cons is that it implements node.js event loop so you must use yode (node.js fork) in order for promises and asynchronous code to work well with the GUI code.. m

虽然它似乎已停止,但我发现这个项目很独特,但它确实是原生的,可以选择添加下降 web 视图。我重新获取了一些 PR 并对其进行了分叉,并且我正在添加 TypeScript 类型和文档,因为它是非常干净/直接的 API,易于构建目标平台文件。这是我的叉子,虽然我想/搜索其他用户添加缺失的部分:https: //github.com/cancerberoSgx/node-gui。缺点是它实现了 node.js 事件循环,所以你必须使用 yode (node.js fork) 以便 promises 和异步代码与 GUI 代码一起工作。m

I wonder if others have experience with this library or forks.

我想知道其他人是否有使用这个库或 fork 的经验。

回答by Tchakabam

Recently also Node-gir may be worth a look: https://github.com/Place1/node-gir

最近还有 Node-gir 可能值得一看:https: //github.com/Place1/node-gir

Allows to use Gnome/Glib/Gobject-based libraries from Nodejs. Will allow you to use GTK+.

允许使用来自 Nodejs 的基于 Gnome/Glib/Gobject 的库。将允许您使用 GTK+。