×

Electron 教程

Electron 教程简介Electron 快速入门Electron 桌面环境集成Electron 在线/离线事件探测Electron 进程支持的 Chrome 命令行开关Electron 环境变量Electron 支持的平台Electron 应用部署Mac App Store 应用提交向导Electron 应用打包Electron 使用原生模块Electron 主进程调试使用 Selenium 和 WebDriverElectron DevTools扩展使用 Pepper Flash 插件使用 Widevine CDM 插件Electron 术语表Electron 离屏渲染Electron 交互式解释器 (REPL)Electron 自动更新功能autoUpdater

Electron API

Electron DOM File对象Electron DOM <webview>Electron window.open 函数

在主进程内可用的模块

Electron app 模块Electron autoUpdater 模块Electron BrowserWindow 模块Electron contentTracing 模块Electron dialog 模块Electron global-shortcut 模块Electron ipcMain 模块Electron menu 模块Electron MenuItem 模块Electron powerMonitor 模块Electron powerSaveBlockerElectron protocol 模块Electron session 模块Electron webContents 模块Electron Tray 模块Electron Locales

在渲染进程(网页)可用模块

Electron desktopCapturer模块Electron ipcRenderer 模块Electron remote 模块Electron webFrame 模块

两种进程都可用的模块

Electron clipboard 模块Electron crashReporter 模块Electron nativeImage 模块Electron screen 模块Electron shell 模块

Electron 开发

Electron 编码规范Electron 源码目录结构Electron 和 NW.js技术上的差异Electron 构建系统概览Electron 构建步骤 (OS X)Electron 构建步骤 (Windows)Electron 构建步骤 (Linux)调试中使用 Symbol ServerElectron 常见问题Electron 版本管理electron window 提交指南自动化持续集成系统(CI)测试Electron 文档风格指南

Electron 构建步骤 (Windows)


遵循下面的引导,在 Windows 上构建 Electron .

前提

如果你现在还没有安装 Windows , modern.ie 有一个 timebombed 版本的 Windows ,你可以用它来构建 Electron.

构建 Electron 完全的依赖于命令行,并且不可通过 Visual Studio. 可以使用任何的编辑器来开发 Electron ,未来会支持 Visual Studio.

注意: 虽然 Visual Studio 不是用来构建的,但是它仍然 必须的 ,因为我们需要它提供的构建工具栏.

注意: Visual Studio 2015 不可用. 请确定使用 MSVS 2013.

获取代码

$ git clone https://github.com/electron/electron.git

Bootstrapping

bootstrap 脚本也是必要下载的构建依赖,来创建项目文件.注意我们使用的是 ninja 来构建 Electron,所以没有生成 Visual Studio 项目.

$ cd electron
$ python scriptbootstrap.py -v

构建

创建 Release  Debug target:

$ python scriptbuild.py

可以只创建 Debug target:

$ python scriptbuild.py -c D

创建完毕, 可以在 out/D(debug target) 或 outR (release target) 下面找到 electron.exe.

64bit Build

为了构建64位的 target,在运行 bootstrap 脚本的时候需要使用 --target_arch=x64 :

$ python scriptbootstrap.py -v --target_arch=x64

其他构建步骤完全相同.

Tests

测试你的修改是否符合项目代码风格,使用:

$ python scriptcpplint.py

测试有效性使用:

$ python scripttest.py

在构建 debug 时为 Tests包含原生模块 (例如 runas) 将不会执行(详情 #2558), 但是它们在构建 release 会起效.

运行 release 构建使用 :

$ python scripttest.py -R

解决问题

Command xxxx not found

如果你遇到了一个错误,类似 Command xxxx not found, 可以尝试使用 VS2012 Command Prompt 控制台来执行构建脚本 .

Fatal internal compiler error: C1001

确保你已经安装了 Visual Studio 的最新安装包 .

Assertion failed: ((handle))->activecnt >= 0

如果在 Cygwin 下构建的,你可能会看到 bootstrap.py 失败并且附带下面错误 :

Assertion failed: ((handle))->activecnt >= 0, file srcwinpipe.c, line 1430

Traceback (most recent call last):
  File "script/bootstrap.py", line 87, in 
    sys.exit(main())
  File "script/bootstrap.py", line 22, in main
    update_node_modules('.')
  File "script/bootstrap.py", line 56, in update_node_modules
    execute([NPM, 'install'])
  File "/home/zcbenz/codes/raven/script/lib/util.py", line 118, in execute
    raise e
subprocess.CalledProcessError: Command '['npm.cmd', 'install']' returned non-zero exit status 3

这是由同时使用 Cygwin Python 和 Win32 Node 造成的 bug.解决办法就是使用 Win32 Python 执行 bootstrap 脚本 (假定你已经在目录 C:Python27 下安装了 Python):

$ /cygdrive/c/Python27/python.exe script/bootstrap.py

LNK1181: cannot open input file 'kernel32.lib'

重新安装 32位的 Node.js.

Error: ENOENT, stat 'C:UsersUSERNAMEAppDataRoamingnpm'

简单创建目录 应该可以解决问题:

$ mkdir ~AppDataRoamingnpm

node-gyp is not recognized as an internal or external command

如果你使用 Git Bash 来构建,或许会遇到这个错误,可以使用 PowerShell 或 VS2012 Command Prompt 来代替 .


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)