Node-webkit Web technology to write desktop applications

Source: Internet
Author: User

Node-webkit is a chromium and node. JS-based application runner that allows developers to write desktop applications using Web technology. Developed with web technology, supports node. JS and is compatible with multiple platforms (Window/mac/linux).

Project Address: Https://github.com/rogerwang/node-webkit

Download: http://dl.node-webkit.org/

Basic Operation (Window System):

1, download the Node-webkit version of the system, run the Nw.exe in the directory, the display instructions can be run normally.


2, the establishment of Package.json and index.html, compressed into Test.zip file package, directly dragged to the Test.zip package to Nw.exe to open Nw.exe mode.

3, the Text.zip and Nw.exe packaged into Test.exe,window may command

Copy/b Nw.exe+test.ziptest.exe

Now run the Test.exe directly to open it.

Note: Nw.exe must be placed in front of the + sign, the merge command needs to be executed with CMD, win8 "Copy-item: Cannot find the positional parameters that accept the actual parameter ' B.exe '."

4, install Enigma Virtual Box (http://enigmaprotector.com/en/aboutvb.html), packaging all files for an executable EXE program.


Package.json:

Package.json is a project configuration file that configures window borders, toolbars, fullscreen, window size and position when open, icons, node. js startup files, default open pages, window maximum and minimum dimensions, and so on. The default page setting is main. For detailed parameters, see:

Https://github.com/rogerwang/node-webkit/wiki/Manifest-format

node. JS Module Extensions:

You can download Nodejs's various module extensions in the catalog, which are stored in the directory node_modules.

Call the module form in the page:

var imagemin= require (' imagemin ');//to do something ...


node. js built-in servers:

Reference: http://www.infoq.com/cn/news/2011/11/tyq-nodejs-static-file-server/

demo:http://download.csdn.net/detail/jyy_12/7924781

Http.js:

var PORT = 8000;var http = require (' http '), var url = require (' URL '), var path = require (' path '); var fs = require (' FS '); var MIME = require ('./mime '). Types;var Server = http.createserver (function (request, response) {var pathname = Url.parse (r    Equest.url). Pathname; var realpath = "Test" + pathname;var ext = path.extname (realpath); ext = ext? Ext.slice (1): ' Unknown '; var contentType = Mime[ext] | |    "Text/plain"; Path.exists (Realpath, function (exists) {if (!exists) {Response.writehead (404, {' Conte             Nt-type ': ContentType});            Response.Write ("This request URL" + pathname + "is not found on the this server.");        Response.End (); } else {fs.readfile (Realpath, "binary", function (err, file) {if (err) {RE                     Sponse.writehead ($, {' Content-type ': ContentType});                Response.End (ERR);          } else {          Response.writehead ($, {' Content-type ': ContentType});                     Response.Write (File, "binary");                Response.End ();        }            }); }    });}); Server.listen (port); Console.log ("Server runing at Port:" + Port + ".");

Package.json:

{  "name": "Nw-demo",  "main": "Http://localhost:8000/test.html",  "Nodejs": True,  "Node-main": " Http.js ",  " window ": {" width ": +," height ": +," Transparent ": True  }}

Mime.js:

Exports.types = {    "css": "Text/css",    "gif": "Image/gif",    "html": "Text/html",    "ico": "Image/x-icon",    "JPEG": "Image/jpeg", "    jpg": "Image/jpeg",    "JS": "Text/javascript",    "JSON": "Application/json",    "PDF": "Application/pdf",    "png": "Image/png",    "svg": "Image/svg+xml",    "swf": "application/ X-shockwave-flash ",    " TIFF ":" Image/tiff ",    " TXT ":" Text/plain ",    " wav ":" Audio/x-wav ",    " WMA ":" Audio/x-ms-wma ",    " wmv ":" Video/x-ms-wmv ",    " xml ":" Text/xml "};<strong></strong>


Node-webkit Disadvantages:

After the final packaging of the file larger, simple node-webkit required files will be nearly 60M, compression will also be nearly 25M.

Resources:

Official Api:https://github.com/rogerwang/node-webkit/wiki

Recommended (more detailed Chinese course): http://www.cnblogs.com/xuanhun/tag/node-webkit/

http://pan.baidu.com/share/link?shareid=3743096074&uk=2754670725

http://damoqiongqiu.iteye.com/blog/2010720

Http://www.baidufe.com/item/1fd388d6246c29c1368c.html

Node-webkit instances:

Https://github.com/zcbenz/nw-sample-apps

Https://github.com/rogerwang/node-webkit/wiki/List-of-apps-and-companies-using-node-webkit

Node-webkit Web technology to write desktop applications

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.