Javascript 是否可以使用 node.js 创建桌面应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8794140/
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-08-24 07:31:58  来源:igfitidea点击:

Is it possible to create desktop applications with node.js?

javascriptnode.jswindow

提问by itamarb

I've created an application using node.js, and I'm interested to know if it's possible to pack the client side (js, html ,css) and the server side into a standalone application (that doesn't required browser).

我已经使用 node.js 创建了一个应用程序,我很想知道是否可以将客户端(js、html、css)和服务器端打包到一个独立的应用程序中(不需要浏览器)。

回答by thejh

https://github.com/rogerwang/node-webkitis a project with the goal of running an instance of the webkit browser engine in the same process as nodejs. It allows you to directly use nodes API in the browser. It currently only works on linuxworks on Windows, Mac and Linux now.

https://github.com/rogerwang/node-webkit是一个项目,其目标是在与 nodejs 相同的进程中运行 webkit 浏览器引擎的实例。它允许您直接在浏览器中使用节点 API。它目前仅适用于 linux,现在适用于 Windows、Mac 和 Linux。

回答by benedict_w

I am also investigating this.

我也在调查这个。

AppJS is looking very promising as an api for building cross platform desktop apps using HTML5, CSS3 and NodeJS. Unfortunately for me it's probably not well enough developed for my next project.

AppJS 作为使用 HTML5、CSS3 和 NodeJS 构建跨平台桌面应用程序的 api 看起来非常有前途。不幸的是,对于我的下一个项目来说,它可能还不够完善。

回答by Chris Sainty

I have been investigating this very topic since the node-webkitproject was announced.
I have a blog post about my early efforts http://csainty.blogspot.com/2012/01/creating-desktop-apps-with-nodejs.html

自从node-webkit项目宣布以来,我一直在研究这个话题。
我有一篇关于我早期努力的博客文章http://csainty.blogspot.com/2012/01/creating-desktop-apps-with-nodejs.html

In the latest code drop you can now specify an application closedown callback, which makes it easy now to instantiate your applicaton and a localhost webserver when the application is started. Then close it all down cleanly when it is closed.

在最新的代码中,您现在可以指定应用程序关闭回调,这使得在应用程序启动时实例化您的应用程序和本地主机网络服务器变得容易。然后在关闭时将其全部关闭。

This make it pretty easy to port a web application to the desktop depending on what other server dependencies you might have.

这使得将 Web 应用程序移植到桌面变得非常容易,具体取决于您可能拥有的其他服务器依赖项。

var nwebkit = require('node-webkit'),
    http = require('http');

var server = http.createServer(function (req, res) {
    // If you need it you can create a local web server
    // You can also use express etc if preferred
    }).listen(3000, '127.0.0.1');

nwebkit.init({
    'url': 'index.html',
    'width': 800,
    'height': 600,
    'onclose': function() {
       server.close();
    }
});

回答by MhdSyrwan

you can write a desktop app using Qt with node

您可以使用 Qt 和 node 编写桌面应用程序

see this binding

看到这个绑定

https://github.com/arturadib/node-qt

https://github.com/arturadib/node-qt