Windows 下的 electron 开发笔记一

33次阅读

共计 1122 个字符,预计需要花费 3 分钟才能阅读完成。

前言
根据公司业务需求,使用 electron 开发桌面 BrowserWindow 应用。
参考 API:Electron 文档
安装与配置
安装工具
node(LTS 版)git 命令行工具
搭建项目
初始化:
$ npm init

安装 electron:
$ npm install electron –save-dev

软件打包
安装打包工具:
$ npm install –save-dev electron-packager

打包基本命令:
electron-packager {location} {name} {platform} {architecture} {version} {options}

location:项目所在路径
name of project:打包的项目名字
platform:确定了你要构建哪个平台的应用(Windows、Mac 还是 Linux)
architecture:决定了使用 x86 还是 x64 还是两个架构都用
version:electron 的版本
options:可选选项

在 package.json 中添加配置项:
“packager”: “electron-packager ./ writ win x86 –app–version=2.0.6 –overwrite –icon=./favicon.ico”

执行:
$ npm run-script packager

环境依赖

.netframework 4.5.1
python2.7
Visual C++ Build Tools

一键安装:
$ npm install –global –production windows-build-tools

环境设置:
$ npm config set msvs_version 2015

若出现 vc2015 安装失败情况,请自行安装 SP1windows6.1-KB976932 补丁
插件依赖

node-gyp Node 编写的跨平台命令行工具,用于编译 Node.js 的原生插件模块
$ npm install -g node-gyp

ffi 用以调用动态库的 Node.js 插件
$ npm install ffi –save

buffer 提供与 Node.js 的 Buffer 完全相同的缓冲区插件
$ npm install buffer –save

iconv-lite 用于在 Node.js 当中处理在各种操作系统出现的各种奇特编码,该模块不提供读写文件的操作,只提供文件编码转换的功能
$ npm install iconv-lite –save

electron-rebuild 用以重编译适合 electron 的模块
$ npm install electron-rebuild –save-dev

$ ./node_modules/.bin/electron-rebuild ./node_modules/ffi

占坑

正文完
 0