nodewebkitV0.21.6版本的学习 1、下载 2、hello world 程序

https://nwjs.io/

nodewebkitV0.21.6版本的学习
1、下载
2、hello world 程序

建议下载sdk版本,有调试功能,正式发布时,使用normal版本

nodewebkitV0.21.6版本的学习
1、下载
2、hello world 程序

下载以后解压,得到的文件目录如下

 nodewebkitV0.21.6版本的学习
1、下载
2、hello world 程序

点击nw.exe,显示如下

 nodewebkitV0.21.6版本的学习
1、下载
2、hello world 程序

2、hello world 程序

在nw.exe同级的目录下,新建文件夹HelloWorld

nodewebkitV0.21.6版本的学习
1、下载
2、hello world 程序

载文件夹中,新建一个index.html文件

<!DOCTYPE html>
<html>
  <head>
    <title>Hello World!</title>
  </head>
  <body>
    <h1>Hello node-webkit!</h1></body>
</html>

同一级目录下再建一个package.json

{
  "name": "HelloWorld",
  "main": "index.html"
}

其中name要与文件夹的名称保持一致(包括大小写也要保持一致),main指向建立的html文件

拖拽HelloWorld文件到nw.exe,得到如下效果

nodewebkitV0.21.6版本的学习
1、下载
2、hello world 程序

在HelloWorld文件中,选中index.html和package.json两个文件,并对其进行压缩,得到如下结果

nodewebkitV0.21.6版本的学习
1、下载
2、hello world 程序

注意:这里压缩一定不能包含文件夹

将压缩文件拷贝到与nw.exe同级的目录下,并将压缩文件后缀改为.nw,如图所示

nodewebkitV0.21.6版本的学习
1、下载
2、hello world 程序

在该处按下shfit键,右键鼠标选择在此处打开命令窗口,输入copy /b nw.exe+HelloWorld.nw HelloWorld.exe,执行结果如图

 nodewebkitV0.21.6版本的学习
1、下载
2、hello world 程序

注意:命令中的参数是有顺序的,不能够对调

文件中多了一个HelloWorld.exe文件

nodewebkitV0.21.6版本的学习
1、下载
2、hello world 程序

点击此文件可以查看到程序运行结果,但把文件放置于其他位置时,会执行失败,因为exe的执行需要依赖一些dll文件才能执行,故需要一款打包工具将其打包到一起,这里使用的是Enigma Virtual Box ,可以通过http://enigmaprotector.com/assets/files/enigmavb.exe下载,安装完成以后的界面如图所示

nodewebkitV0.21.6版本的学习
1、下载
2、hello world 程序

将HelloWorld.exe程序作为输入文件,并将除HelloWorld和HelloWorld.exe以外的其它文件全部拖拽到Virtual Box中,如图所示

nodewebkitV0.21.6版本的学习
1、下载
2、hello world 程序

 点击process运行

nodewebkitV0.21.6版本的学习
1、下载
2、hello world 程序

生成HelloWorld_boxed.exe文件,该文件即为最终文件,无论放置在任意位置都可以运行