Node-webkit allows web technology to write desktop applications, and node-webkitweb

Source: Internet
Author: User

Node-webkit allows web technology to write desktop applications, and node-webkitweb

Node-webkit is an application program running based on Chromium and node. js. It allows developers to write desktop applications using web technology. Developed using web technology, it supports node. js and is compatible with multiple platforms (Windows, mac, and linux ).

Project address: https://github.com/rogerwang/node-webkit

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

 

Basic operations (window system ):

1. Download the corresponding node-webkit.pdf of the system and run nw.exe in the directory.


2. Create package.jsonand index.html, compress them into the test.zip package, and drag them directly to the test.zip package to nw.exeto open it in nw.exe mode.

3. Package text.zipand n1_exeinto test.exe. commands may be run in the window.

Copy/B n1_exe1_test.ziptest.exe

Run test.exe directly.

Note: nw.exe must be placed before the plus (+). Run the merge command in cmd. The powershell command in win8 reports the error "copy-Item: unable to find the parameter 'B .exe' format parameter ".

4. Install the Enigma Virtual Box (http://enigmaprotector.com/en/aboutvb.html) and package all the files into an executable exe program.


 

Package. json:

Package. json is the configuration file of the project. You can configure the window border, toolbar, full screen, window size and position, icon, and node. js Startup File, default page opened, maximum and minimum size of window, etc. The default page is set to main. For details about the parameters, see:

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

 

Node. js module extension:

You can download various node. js module extensions in the directory and store them in the node_modules directory.

Call the module form on the page:

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


Node. js built-in Server:

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(request.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, {                'Content-Type': contentType            });             response.write("This request URL " + pathname + " was not found on this server.");            response.end();        } else {            fs.readFile(realPath, "binary", function (err, file) {                if (err) {                    response.writeHead(500, {                        'Content-Type': contentType                    });                     response.end(err);                } else {                    response.writeHead(200, {                        '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":400,"height":300,"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>


Disadvantages of node-webkit:

The final package contains a large number of files. The size of files required by node-webkit alone is nearly 60 MB, and the size after compression is nearly 25 MB.

 

References:

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

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

Http://pan.baidu.com/share/link? Consumer id = 3743096074 & uk = 2754670725

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

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

 

Node-webkit instance:

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

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


What is the difference between desktop application development and WEB applications?

Desktop applications are easy to use, such as desktop pet software or mini games. WEB applications provide you with a platform similar to an operating system on the Internet, such as tx web qq.

What is a web application? What is a desktop program?

WEB applications are web applications that use WEB browsers to view web pages.
Desktop applications are software systems developed using development tools. They exist in the form of files. For example, QQ and WORD are 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.