Download Node-webkit
Click here:
Https://github.com/rogerwang/node-webkit
Locate the Downloads section and download the Node-webkit precompiled package for the corresponding platform. (For ease of introduction, this article is all about the Windows platform, OSX and Linux platform operations similar, do not specifically explained.) )
After downloading the extract, you can see the following content:
Double-click Nw.exe to run directly and see the following interface to show that everything is OK and can be run on your machine:
Hello NW
Let's go first, hello world!.
Build a example1.html that reads as follows:
<!DOCTYPE html>
Build a Package.json in the same level directory, with the following content:
{ "name": "nw-demo", "main": "example1.html"}
Well, use the compression tool on your machine, rar or 7z or god horse, to compress the two files into Exampl1.zip, as shown in:
Note that it doesn't matter what tool to compress, but be sure to compress it into a zip format.
Copy the Example1.zip to a directory similar to Nw.exe, such as:
Then use the mouse to drag the example1.zip to the Nw.exe to run (with the command line can also, but under Windows or directly drag a little more cool), the effect such as:
So, the first example is done, and then you can play it yourself.
According to the official pointers, Example1.zip can be renamed EXAMPLE1.NW, so it looks taller. But because the small monk's big always is relatively low, the private thought uses. zip as the suffix also has nothing to do.
A little JS.The first example code is very simple, you can add some of your most familiar JS code, such as this:
<!DOCTYPE html>
Obviously, there are a lot of HTML5 idioms, which is certainly necessary, right? Because WebKit in Google's femdom has already become the HTML5 pioneer!
Packaging and distribution
For example, it is clear that these DLLs and Pak files are indispensable for our application to run (for what each file is for, see the official description document).
So, for the simple application of the example1 we do, how can we let our users run it? Of course, let our users to download Node-webkit and then unzip the operation, this is also a way, so we just throw the Example1.zip file to him on it.
But it always feels a bit strange, if you can package all the relevant content into a separate EXE file, such as packaged into Example1.exe, so that users can directly double-click to run, which is obviously excellent.
Ok,let ' s go!
First, we will merge Example1.zip and Nw.exe to form a new file named Example1.exe, which we can do with the copy command under Windows command line:
copy /b nw.exe+example1.zip example1.exe
Note that the nw.exe must be placed in front of the + sign.
This generates a file named Example1.exe, double-click the file to see the same effect as the first example. Obviously, this example1.exe is still dependent on those DLL files to run, so we need a packaging tool to help us package these example1.exe and DLL files together, it's Enigma Virtual Box, You can click here to download the installation:
Http://enigmaprotector.com/assets/files/enigmavb.exe
After the installation is complete, you see the following interface:
Packaging process (Follow the configuration in the diagram):
Click the process button in the lower right corner to start packing and finally get a file named Example1_boxed.exe. Copy this file to any other directory to double-click, if you can run smoothly, the packaging success! You can distribute it to your users!
The official documentation also describes several other packaging distribution methods, but it does not look very practical and interesting to see here:
Https://github.com/rogerwang/node-webkit/wiki/How-to-package-and-distribute-your-apps
Node-webkit Getting Started