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
Is it possible to create desktop applications with node.js?
提问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
看到这个绑定
回答by alessioalex
There have been some attempts, but at the moment there isn't a proper library for this:
已经进行了一些尝试,但目前还没有一个合适的库:
http://www.readwriteweb.com/hack/2011/04/build-desktop-apps-with-nodejs.php
https://github.com/appcelerator-titans/nodejs-desktop-prototype
http://www.readwriteweb.com/hack/2011/04/build-desktop-apps-with-nodejs.php
https://github.com/appcelerator-titans/nodejs-desktop-prototype