非常教程

Electron参考手册

指南·开发 | Guides: Development

构建说明(Windows) | Build Instructions (Windows)

按照下面的指导在Windows上构建Electron。

先决条件

  • Windows 7 / Server 2008 R2或更高版本
  • Visual Studio 2015 Update 3 - 免费下载VS 2015 Community Edition
  • Python 2.7
  • Node.js
  • Git

  • 如果您打算创建完整的发行版,symstore.exe则用于Windows的调试工具用于从.pdb文件创建符号存储库。

如果您目前没有Windows安装,则dev.microsoftedge.com会提供可用于构建Electron的Timebombed版本的Windows。

Building Electron完全使用命令行脚本完成,无法使用Visual Studio完成。您可以使用任何编辑器开发Electron,但支持使用Visual Studio进行构建将在未来发布。

注意:尽管Visual Studio不用于构建,但它仍然是必需的,因为我们需要它提供的构建工具链。

获取代码

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

引导

引导脚本将下载所有必要的构建依赖项并创建构建项目文件。请注意,我们正在使用ninja构建Electron,因此不会生成Visual Studio项目。

$ cd electron
$ python script\bootstrap.py -v

构建

构建Release和Debug目标:

$ python script\build.py

您也可以只构建Debug目标:

$ python script\build.py -c D

构建完成后,您可以electron.exeout\D(调试目标)下或out\R(释放目标)下找到。

32位版本

要为32位目标构建,需要--target_arch=ia32在运行引导脚本时通过:

$ python script\bootstrap.py -v --target_arch=ia32

其他构建步骤完全相同。

Visual Studio项目

要生成Visual Studio项目,您可以传递--msvs参数:

$ python script\bootstrap.py --msvs

清除

清理构建文件:

$ npm run clean

仅清理outdist目录:

$ npm run clean-build

注意:这两个clean命令都需要bootstrap在构建之前再次运行。

测试

请参阅构建系统概述:测试

故障排除

Command xxxx not found

如果遇到类似错误Command xxxx not found,您可以尝试使用VS2015 Command Prompt控制台执行构建脚本。

Fatal internal compiler error: C1001

确保安装了最新的VisualStudio更新。

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

如果在Cygwin下构建,您可能会看到bootstrap.py以下错误失败:

Assertion failed: ((handle))->activecnt >= 0, file src\win\pipe.c, line 1430

Traceback (most recent call last):
  File "script/bootstrap.py", line 87, in <module>
    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导致的错误引起的。解决方案是使用Win32 Python来执行引导脚本(假设你已经安装了Python C:\Python27):

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

LNK1181: cannot open input file ‘kernel32.lib’

尝试重新安装32位Node.js.

Error: ENOENT, stat ‘C:\Users\USERNAME\AppData\Roaming\npm’

只需制作该目录即可解决问题:

$ mkdir ~\AppData\Roaming\npm

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

如果您使用Git Bash进行构建,则可能会出现此错误,您应该改用PowerShell或VS2015命令提示符。

Electron

Electron 是一个使用 JavaScript, HTML 和 CSS 等 Web 技术创建原生程序的框架,它负责比较难搞的部分,你只需把精力放在你的应用的核心上即可。

主页 https://electron.atom.io/
源码 https://github.com/electron/electron
发布版本 1.7.9

Electron目录

1.指南 | Guides
2.指南·开发 | Guides: Development
3.Webview 组件 |
4.加速器 | Accelerator
5.API
6.API·对象 | API·Objects
7.app
8.autoUpdater
9.浏览器总览 | BrowserView
10.浏览器窗口 | BrowserWindow
11.浏览器窗口代理 | BrowserWindowProxy)
12.ClientRequest
13.剪贴板 | clipboard
14.内容追踪 | contentTracing
15.小型文字档案 | Cookies
16.crashReporter
17.调试器 | Debugger
18.desktopCapturer
19.dialog
20.电子下载 | DownloadItem
21.环境变量 | Environment Variables
22.无框窗口 | Frameless Window
23.globalShortcut
24.IncomingMessage
25.ipcMain
26.IPC渲染器 | ipcRenderer
27.语言环境 | Locales
28.画面 | Menu
29.MenuItem
30.本地图像 | nativeImage
31.net
32.通知 | Notification
33.权限监控 | powerMonitor
34.权限存储拦截器 | powerSaveBlocker
35.处理 | process
36.协议 | protocol
37.远程 | remote
38.sandbox
39.屏幕 | screen
40.会话 | session
41.shell
42.系统表现 | systemPreferences
43.触摸板 | TouchBar
44.触摸板按钮 | TouchBarButton
45.触摸板颜色选择器 | TouchBarColorPicker
46.触摸板组 | TouchBarGroup
47.触摸板标签 | TouchBarLabel
48.触摸板弹出框 | TouchBarPopover
49.触摸板清理 | TouchBarScrubber
50.触摸板分段控制 | TouchBarSegmentedControl
51.触摸板滑块 | TouchBarSlider
52.触摸板间隔 | TouchBarSpacer
53.Tray
54.网页内容 | webContents
55.网页框架 | webFrame
56.网页要求 | WebRequest
57.窗口开启 | window.open