ita*_*arb 58 javascript window node.js
我使用node.js创建了一个应用程序,我很想知道是否可以将客户端(js,html,css)和服务器端打包到一个独立的应用程序(不需要浏览器).
the*_*ejh 45
https://github.com/rogerwang/node-webkit是一个项目,其目标是在与nodejs相同的进程中运行webkit浏览器引擎的实例.它允许您直接在浏览器中使用节点API.它目前仅适用于 Windows,Mac和Linux上的Linux.
自node-webkit项目宣布以来,我一直在研究这个话题.
我有一篇关于我早期工作的博客文章http://csainty.blogspot.com/2012/01/creating-desktop-apps-with-nodejs.html
在最新的代码中,您现在可以指定应用程序关闭回调,这使得现在可以轻松地在应用程序启动时实例化您的应用程序和localhost Web服务器.然后在关闭时将它们全部干净地关闭.
这使得将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();
}
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
64096 次 |
最近记录: |