1. 创建项目页面
在文件夹新建文件夹命名为
app,在app内新建index.html页面,页面内容随意。
2.初始化配置文件

image.png
输入
npm init初始化package.json
npm init

image.png
3. 运行 和 打包 依赖
npm install nwjs-builder-phoenix --save-dev
安装完成 修改
pcakage.json配置
{
"name": "myapp",
"version": "1.0.0",
"description": "nwjs使用",
"main": "app/index.html",
"window": {
"title": "hello world",
"icon": "app/favicon.ico",
"width": 1920,
"height": 1080,
"toolbar": false,
"frame": true,
"resizable": true,
"position": "center",
"transparent": false,
"show_in_taskbar": true,
"show": true
},
"node-remote": "*://*",
"scripts": {
"dist": "build --tasks win-x86,win-x64,linux-x86,linux-x64,mac-x64 --mirror https://mirrors.huaweicloud.com/nwjs/ .",
"start": "run --x86 --mirror https://mirrors.huaweicloud.com/nwjs/ ."
},
"build": {
"nwVersion": "0.56.1"
},
"author": "",
"license": "ISC",
"dependencies": {},
"devDependencies": {
"nwjs-builder-phoenix": "^1.15.0"
}
}
注意:
"build": {"nwVersion": "0.56.1"}这个是nwjs版本,请选择适合您的版本
备用地址 :https://npmmirror.com/mirrors/nwjs/
- 运行指令
npm run start
此命令运行的是sdk版本的即开发版,主要方便调试,可以F12或者右键打开开发者工具

image.png
- 打包指令
npm run dist
该命令会根据script配置的打包平台,进行打包,打包完最终文件会在项目目录下dist文件夹内

image.png