Skip to main content

Electron 4.0.0

· 14 min read

Electron 团队非常高兴地宣布,Electron 4 的稳定版本现已发布!你可以从 electronjs.org 安装它,也可以通过 npm install electron@latest 从 npm 安装它。此版本包含升级、修复和新功能,我们迫不及待地想看到你使用它们构建的作品。阅读更多有关此版本的详细信息,并在探索过程中分享你的任何反馈!

¥The Electron team is excited to announce that the stable release of Electron 4 is now available! You can install it from electronjs.org or from npm via npm install electron@latest. The release is packed with upgrades, fixes, and new features, and we can't wait to see what you build with them. Read more for details about this release, and please share any feedback you have as you explore!


有什么新功能?

¥What's New?

Electron 的大部分功能由构成 Electron 的核心组件 Chromium、Node.js 和 V8 提供。因此,Electron 团队的一个关键目标是尽可能跟上这些项目的变化,让构建 Electron 应用的开发者能够访问新的 Web 和 JavaScript 功能。为此,Electron 4 对这些组件进行了重大版本升级;Electron v4.0.0 包含 Chromium 69.0.3497.106、Node 10.11.0 和 V8 6.9.427.24

¥A large part of Electron's functionality is provided by Chromium, Node.js, and V8, the core components that make up Electron. As such, a key goal for the Electron team is to keep up with changes to these projects as much as possible, providing developers who build Electron apps access to new web and JavaScript features. To this end, Electron 4 features major version bumps to each of these components; Electron v4.0.0 includes Chromium 69.0.3497.106, Node 10.11.0, and V8 6.9.427.24.

此外,Electron 4 还包含对 Electron 特定 API 的更改。你可以在下面找到 Electron 4 主要变更的摘要;查看完整的变更列表,请查看 Electron v4.0.0 版本说明

¥In addition, Electron 4 includes changes to Electron-specific APIs. You can find a summary of the major changes in Electron 4 below; for the full list of changes, check out the Electron v4.0.0 release notes.

禁用 remote 模块

¥Disabling the remote Module

现在,你可以出于安全原因禁用 remote 模块。该模块可以在 BrowserWindowwebview 标签下禁用:

¥You now have the ability to disable the remote module for security reasons. The module can be disabled for BrowserWindows and for webview tags:

// BrowserWindow
new BrowserWindow({
webPreferences: {
enableRemoteModule: false
}
})

// webview tag
<webview src="http://www.google.com/" enableremotemodule="false"></webview>

请参阅 BrowserWindow<webview> 标签 文档了解更多信息。

¥See the BrowserWindow and <webview> Tag documentation for more information.

过滤 remote.require() / remote.getGlobal() 请求

¥Filtering remote.require() / remote.getGlobal() Requests

如果你不想完全禁用 remote 模块,此功能非常有用。你的渲染器进程或 webview,但希望对通过 remote.require 请求哪些模块有额外的控制权。

¥This feature is useful if you don't want to completely disable the remote module in your renderer process or webview but would like additional control over which modules can be required via remote.require.

当渲染进程通过 remote.require 调用模块时,会在 app 模块 上引发 remote-require 事件。你可以在事件(第一个参数)上调用 event.preventDefault() 来阻止模块加载。require 发生的 WebContents 实例 作为第二个参数传递,模块名称作为第三个参数传递。相同的事件也会在 WebContents 实例上发出,但在这种情况下,唯一的参数是事件和模块名称。在这两种情况下,你都可以通过设置 event.returnValue 的值来返回自定义值。

¥When a module is required via remote.require in a renderer process, a remote-require event is raised on the app module. You can call event.preventDefault() on the the event (the first argument) to prevent the module from being loaded. The WebContents instance where the require occurred is passed as the second argument, and the name of the module is passed as the third argument. The same event is also emitted on the WebContents instance, but in this case the only arguments are the event and the module name. In both cases, you can return a custom value by setting the value of event.returnValue.

// Control `remote.require` from all WebContents:
app.on('remote-require', function (event, webContents, requestedModuleName) {
// ...
});

// Control `remote.require` from a specific WebContents instance:
browserWin.webContents.on(
'remote-require',
function (event, requestedModuleName) {
// ...
},
);

类似地,调用 remote.getGlobal(name) 时会引发 remote-get-global 事件。这与 remote-require 事件的工作方式相同:调用 preventDefault() 以防止返回全局变量,并设置 event.returnValue 返回自定义值。

¥In a similar fashion, when remote.getGlobal(name) is called, a remote-get-global event is raised. This works the same way as the remote-require event: call preventDefault() to prevent the global from being returned, and set event.returnValue to return a custom value.

// Control `remote.getGlobal` from all WebContents:
app.on(
'remote-get-global',
function (event, webContents, requrestedGlobalName) {
// ...
},
);

// Control `remote.getGlobal` from a specific WebContents instance:
browserWin.webContents.on(
'remote-get-global',
function (event, requestedGlobalName) {
// ...
},
);

更多信息,请参阅以下文档:

¥For more information, see the following documentation:

JavaScript 访问“关于”面板

¥JavaScript Access to the About Panel

在 macOS 上,你现在可以调用 app.showAboutPanel() 以编程方式显示“关于”面板,就像点击通过 {role: 'about'} 创建的菜单项一样。请参阅 showAboutPanel 文档 获取更多信息

¥On macOS, you can now call app.showAboutPanel() to programmatically show the About panel, just like clicking the menu item created via {role: 'about'}. See the showAboutPanel documentation for more information

控制 WebContents 后台节流

¥Controlling WebContents Background Throttling

WebContents 实例现在拥有一个方法 setBackgroundThrottling(allowed),用于在页面处于后台时启用或禁用计时器和动画的节流。

¥WebContents instances now have a method setBackgroundThrottling(allowed) to enable or disable throttling of timers and animations when the page is backgrounded.

let win = new BrowserWindow(...)
win.webContents.setBackgroundThrottling(enableBackgroundThrottling)

请参阅 setBackgroundThrottling 文档 了解更多信息。

¥See the setBackgroundThrottling documentation for more information.

重大变化

¥Breaking Changes

不再支持 macOS 10.9

¥No More macOS 10.9 Support

Chromium 不再支持 macOS 10.9(OS X Mavericks),因此也不再支持 Electron 4.0 及更高版本也不支持它

¥Chromium no longer supports macOS 10.9 (OS X Mavericks), and as a result Electron 4.0 and beyond does not support it either.

单实例锁定

¥Single Instance Locking

以前,要使你的应用成为单实例应用(确保在任何给定时间只有一个应用实例在运行),你可以使用 app.makeSingleInstance() 方法。从 Electron 4.0 开始,你必须使用 app.requestSingleInstanceLock() 选项。该方法的返回值指示你的应用的该实例是否成功获得了锁。如果它未能获得锁,你可以假设应用的另一个实例已经使用该锁运行并立即退出。

¥Previously, to make your app a Single Instance Application (ensuring that only one instance of your app is running at any given time), you could use the app.makeSingleInstance() method. Starting in Electron 4.0, you must use app.requestSingleInstanceLock() instead. The return value of this method indicates whether or not this instance of your application successfully obtained the lock. If it failed to obtain the lock, you can assume that another instance of your application is already running with the lock and exit immediately.

如需查看使用 requestSingleInstanceLock() 的示例以及 查看 app.requestSingleInstanceLock() 及相关方法的文档second-instance 事件 等不同平台的细微行为信息。

¥For an example of using requestSingleInstanceLock() and information on nuanced behavior on various platforms, see the documentation for app.requestSingleInstanceLock() and related methods and the second-instance event.

win_delay_load_hook

为 Windows 构建原生模块时,模块的 binding.gyp 中的 win_delay_load_hook 变量必须为 true(这是默认值)。如果此钩子不存在,则原生模块将无法在 Windows 上加载,并显示类似 Cannot find module 的错误消息。更多信息请参见 查看原生模块指南

¥When building native modules for windows, the win_delay_load_hook variable in the module's binding.gyp must be true (which is the default). If this hook is not present, then the native module will fail to load on Windows, with an error message like Cannot find module. See the native module guide for more information.

弃用

¥Deprecations

以下重大变更计划在 Electron 5.0 中进行,因此在 Electron 4.0 中已弃用。

¥The following breaking changes are planned for Electron 5.0, and thus are deprecated in Electron 4.0.

nativeWindowOpen-ed 已禁用 Node.js 集成 Windows

¥Node.js Integration Disabled for nativeWindowOpen-ed Windows

从 Electron 5.0 开始,使用 nativeWindowOpen 选项打开的子窗口将始终禁用 Node.js 集成。

¥Starting in Electron 5.0, child windows opened with the nativeWindowOpen option will always have Node.js integration disabled.

webPreferences 默认值

¥webPreferences Default Values

当创建一个包含 webPreferences 选项集的新 BrowserWindow 时,以下 webPreferences 选项默认值将被弃用,取而代之的是下面列出的新默认值:

¥When creating a new BrowserWindow with the webPreferences option set, the following webPreferences option defaults are deprecated in favor of new defaults listed below:

属性已弃用的默认值新默认值
contextIsolationfalsetrue
nodeIntegrationtruefalse
webviewTag如果设置,则为 nodeIntegration 的值,否则为 truefalse

请注意:目前,一个已知 bug (#9736) 会在 contextIsolation 开启时阻止 webview 标签工作。请持续关注 GitHub 问题以获取最新信息!

¥Please note: there is currently a known bug (#9736) that prevents the webview tag from working if contextIsolation is on. Keep an eye on the GitHub issue for up-to-date information!

了解更多关于上下文隔离、Node 集成以及 Electron 安全文档 中的 webview 标签的信息。

¥Learn more about context isolation, Node integration, and the webview tag in the Electron security document.

Electron 4.0 仍将使用当前默认值,但如果你未为其指定明确的值,则会看到弃用警告。为了让你的应用为 Electron 5.0 做好准备,请为这些选项使用明确的值。查看 BrowserWindow 文档 了解每个选项的详细信息。

¥Electron 4.0 will still use the current defaults, but if you don't pass an explicit value for them, you'll see a deprecation warning. To prepare your app for Electron 5.0, use explicit values for these options. See the BrowserWindow docs for details on each of these options.

webContents.findInPage(text[, options])

medialCapitalAsWordStartwordStart 选项已被弃用,因为它们已被上游移除。

¥The medialCapitalAsWordStart and wordStart options have been deprecated as they have been removed upstream.

应用反馈计划

¥App Feedback Program

我们在 Electron 3.0 开发过程中制定的 应用反馈计划 非常成功,因此在 4.0 的开发过程中也延续了它。我们衷心感谢 Atlassian、Discord、MS Teams、OpenFin、Slack、Symphony、WhatsApp 以及其他项目成员在 4.0 测试周期中的参与。要了解有关应用反馈计划的更多信息并参与未来的 Beta 版,请参阅 查看我们关于该程序的博客文章

¥The App Feedback Program we instituted during the development of Electron 3.0 was successful, so we've continued it during the development of 4.0 as well. We'd like to extend a massive thank you to Atlassian, Discord, MS Teams, OpenFin, Slack, Symphony, WhatsApp, and the other program members for their involvement during the 4.0 beta cycle. To learn more about the App Feedback Program and to participate in future betas, check out our blog post about the program.

下一步计划

¥What's Next

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。虽然我们谨慎地不对发布日期做出承诺,但我们计划大约每季度发布一次 Electron 的新主要版本及其组件的新版本。查看我们的版本控制文档 了解 Electron 版本控制的更多详细信息。

¥In the short term, you can expect the team to continue to focus on keeping up with the development of the major components that make up Electron, including Chromium, Node, and V8. Although we are careful not to make promises about release dates, our plan is release new major versions of Electron with new versions of those components approximately quarterly. See our versioning document for more detailed information about versioning in Electron.

有关即将推出的 Electron 版本 查看我们的“计划重大变更”文档 中计划的重大变更的信息。

¥For information on planned breaking changes in upcoming versions of Electron, see our Planned Breaking Changes doc.

SQLite 漏洞修复

· 2 min read

已发现一个远程代码执行漏洞“Magellan”,该漏洞影响基于 SQLite 或 Chromium 的软件,包括所有版本的 Electron。

¥A remote code execution vulnerability, "Magellan," has been discovered affecting software based on SQLite or Chromium, including all versions of Electron.


范围

¥Scope

使用 Web SQL 的 Electron 应用会受到影响。

¥Electron applications using Web SQL are impacted.

缓解措施

¥Mitigation

受影响的应用应停止使用 Web SQL 或升级到 Electron 的修补版本。

¥Affected apps should stop using Web SQL or upgrade to a patched version of Electron.

我们已发布 Electron 的新版本,其中包含针对此漏洞的修复:

¥We've published new versions of Electron which include fixes for this vulnerability:

目前尚未收到任何关于此问题的外部报告;然而,受影响的应用会被敦促缓解影响。

¥There are no reports of this in the wild; however, affected applications are urged to mitigate.

更多信息

¥Further Information

此漏洞由腾讯 Blade 团队发现,并已发布 一篇讨论该漏洞的博客文章

¥This vulnerability was discovered by the Tencent Blade team, who have published a blog post that discusses the vulnerability.

要了解有关保护 Electron 应用安全的最佳实践的更多信息,请参阅我们的 安全教程

¥To learn more about best practices for keeping your Electron apps secure, see our security tutorial.

如果你想报告 Electron 中的漏洞,请发送电子邮件至 security@electronjs.org

¥If you wish to report a vulnerability in Electron, email security@electronjs.org.

Electron 应用反馈计划

· 6 min read

Electron 正在致力于缩短发布周期并使其更稳定。为了实现这一点,我们启动了针对大型 Electron 应用的应用反馈计划,以测试我们的 Beta 版本并向我们报告应用特有的问题。这有助于我们优先处理那些能让应用更快升级到下一个稳定版本的工作。

¥Electron is working on making its release cycles faster and more stable. To make that possible, we've started the App Feedback Program for large-scale Electron apps to test our beta releases and report app-specific issues to us. This helps us to prioritize work that will get applications upgraded to our next stable release sooner.

编辑 (2020-05-21):此程序已退役。

¥Edit (2020-05-21): This program has been retired.


谁可以加入?

¥Who can join?

我们对加入此计划的应用的标准和期望包括以下内容:

¥Our criteria and expectations for apps joining this program include the following items:

  • 在 Beta 测试期间,对你的应用进行超过 10,000 小时的用户测试

    ¥Test your app during the beta period for 10,000+ user-hours

  • 安排一位专人每周检查,讨论你应用的 Electron 错误和应用拦截器。

    ¥Have a single point-person who will check in weekly to discuss your app's Electron bugs and app blockers

  • 你同意遵守 Electron 的 行为准则

    ¥You agree to abide by Electron's Code of Conduct

  • 你愿意分享下一个问题中列出的以下信息

    ¥You are willing to share the following information listed in the next question

我的 Electron 应用需要共享哪些信息?

¥What info does my Electron app have to share?

  • 你的应用在任何 Beta 版本中运行的总用户小时数

    ¥Total user-hours your app has been running with any beta release

  • 你的应用正在测试的 Electron 版本(例如 4.0.0-beta.3)

    ¥Version of Electron that your app is testing with (e.g., 4.0.0-beta.3)

  • 任何阻止你的应用升级到 Beta 测试版发布线的错误

    ¥Any bugs preventing your application from upgrading to the release line being beta tested

用户小时数

¥User-hours

我们理解并非每个人都能分享准确的用户数量,但更准确的数据有助于我们判断特定版本的稳定性。我们要求应用承诺至少进行用户小时数的测试,目前整个 Beta 周期的用户小时数为 10,000。

¥We understand not everyone can share exact user numbers, however better data helps us decide how stable a particular release is. We ask that apps commit to testing a minimum number of user-hours, currently 10,000 across the beta cycle.

  • 10 个用户小时可能是 10 个人测试 1 小时,也可能是 1 个人测试 10 小时

    ¥10 user-hours could be 10 people testing for one hour, or one person testing for 10 hours

  • 你可以将测试拆分到不同的 Beta 版本,例如在 3.0.0-beta.2 上测试 5,000 用户小时,然后在 3.0.0-beta.5 上测试 5,000 用户小时。越多越好,但我们理解有些应用无法测试每个 Beta 版本。

    ¥You can split the testing between beta releases, for example test for 5,000 user-hours on 3.0.0-beta.2 and then test for 5,000 user-hours on 3.0.0-beta.5. More is better, but we understand that some applications cannot test every beta release

  • CI 或 QA 工时不计入总计;然而,内部版本仍然有效。

    ¥CI or QA hours do not count towards the total; however, internal releases do count

为什么我的 Electron 应用应该加入?

¥Why should my Electron app join?

你应用的错误将被跟踪,并纳入 Electron 核心团队的关注范围。你的反馈有助于 Electron 团队了解新测试版的运行情况以及需要完成的工作。

¥Your app's bugs will be tracked and be on the core Electron team's radar. Your feedback helps the Electron team to see how the new betas are doing and what work needs to be done.

我的应用信息会公开吗?谁可以看到这些信息?

¥Will my application's info be shared publicly? Who gets to see this info?

不会,你的应用信息不会与公众共享。信息保存在一个私密的 GitHub 仓库中,只有应用反馈计划和 Electron 治理 的成员才能查看。所有成员均同意遵循 Electron 的 行为准则

¥No, your application's information will not be shared with the general public. Information is kept in a private GitHub repo that is only viewable to members of the App Feedback Program and Electron Governance. All members have agreed to follow Electron's Code of Conduct.

注册

¥Sign up

我们目前正在接受有限数量的注册。如果你有兴趣并且能够满足上述要求,请填写此 form 表格。

¥We are currently accepting a limited number of signups. If you are interested and are able to fulfill the above requirements, please fill out this form.

Electron 3.0.0

· 9 min read

Electron 团队非常高兴地宣布,Electron 3 的第一个稳定版本现已从 electronjs.orgnpm install electron@latest 版本发布!它充满了升级、修复和新功能,我们迫不及待地想看看你用它们构建了什么。以下是此版本的详细信息,欢迎你在探索过程中提供反馈。

¥The Electron team is excited to announce that the first stable release of Electron 3 is now available from electronjs.org and via npm install electron@latest! It's jam-packed with upgrades, fixes, and new features, and we can't wait to see what you build with them. Below are details about this release, and we welcome your feedback as you explore.


发布流程

¥Release Process

v3.0.0 的开发过程中,我们试图通过规范化渐进式 Beta 版本的反馈进度,更基于经验地定义稳定版本的标准。如果没有我们的 应用反馈计划 合作伙伴在 Beta 测试周期中提供的早期测试和反馈,v3.0.0 不可能实现。感谢 Atlassian、Atom、Microsoft Teams、Oculus、OpenFin、Slack、Symphony、VS Code 以及其他项目成员的辛勤工作。如果你想参与未来的 Beta 版本,请发送电子邮件至 info@electronjs.org

¥As we undertook development of v3.0.0, we sought to more empirically define criteria for a stable release by formalizing the feedback progress for progressive beta releases. v3.0.0 would not have been possible without our App Feedback Program partners, who provided early testing and feedback during the beta cycle. Thanks to Atlassian, Atom, Microsoft Teams, Oculus, OpenFin, Slack, Symphony, VS Code, and other program members for their work. If you'd like to participate in future betas, please mail us at info@electronjs.org.

变更/新功能

¥Changes / New Features

Electron 工具链的几个重要部分发生了重大变化,包括 Chrome v66.0.3359.181、Node v10.2.0 和 V8 v6.6.346.23.

¥Major bumps to several important parts of Electron's toolchain, including Chrome v66.0.3359.181, Node v10.2.0, and V8 v6.6.346.23.

  • [#12656] 功能:app.isPackaged

    ¥[#12656] feat: app.isPackaged

  • [#12652] 功能:app.whenReady()

    ¥[#12652] feat: app.whenReady()

  • [#13183] 功能:process.getHeapStatistics()

    ¥[#13183] feat: process.getHeapStatistics()

  • [#12485] 功能:win.moveTop() 会将窗口 Z 轴顺序移至顶部

    ¥[#12485] feat: win.moveTop() to move window z-order to top

  • [#13110] 功能:TextField 和 Button API

    ¥[#13110] feat: TextField and Button APIs

  • [#13068] 功能:用于动态日志控制的 netLog API

    ¥[#13068] feat: netLog API for dynamic logging control

  • [#13539] 功能:在沙盒渲染器中启用 webview

    ¥[#13539] feat: enable webview in sandbox renderer

  • [#14118] 功能:fs.readSync 现在支持处理海量文件。

    ¥[#14118] feat: fs.readSync now works with massive files

  • [#14031] 功能:node fs 封装器使 fs.realpathSync.nativefs.realpath.native 可用

    ¥[#14031] feat: node fs wrappers to make fs.realpathSync.native and fs.realpath.native available

重大 API 更改

¥Breaking API changes

  • [#12362] 功能:菜单项顺序控制更新

    ¥[#12362] feat: updates to menu item order control

  • [#13050] 重构:删除了已记录的弃用 API

    ¥[#13050] refactor: removed documented deprecated APIs

    • 有关更多详细信息,请参阅 docs

      ¥See docs for more details

  • [#12477] 重构:移除了 did-get-response-detailsdid-get-redirect-request 事件。

    ¥[#12477] refactor: removed did-get-response-details and did-get-redirect-request events

  • [#12655] 功能:默认禁用拖放导航

    ¥[#12655] feat: default to disabling navigating on drag/drop

  • [#12993] 功能:需要 Node v4.x 或更高版本,并使用 electron npm 模块。

    ¥[#12993] feat: Node v4.x or greater is required use the electron npm module

  • [#12008 #12140 #12503 #12514 #12584 #12596 #12637 #12660 #12696 #12716 #12750 #12787 #12858] 重构:NativeWindow

    ¥[#12008 #12140 #12503 #12514 #12584 #12596 #12637 #12660 #12696 #12716 #12750 #12787 #12858] refactor: NativeWindow

  • [#11968] 重构:menu.popup()

    ¥[#11968] refactor: menu.popup()

  • [#8953] 功能:不再使用 JSON 发送 ipcRenderer.sendSync 的结果

    ¥[#8953] feat: no longer use JSON to send the result of ipcRenderer.sendSync

  • [#13039] 功能:默认忽略 URL 后的命令行参数

    ¥[#13039] feat: default to ignore command line arguments following a URL

  • [#12004] 重构:将 api::Window 重命名为 api::BrowserWindow

    ¥[#12004] refactor: rename api::Window to api::BrowserWindow

  • [#12679] 功能:视觉缩放功能现已默认关闭

    ¥[#12679] feat: visual zoom now turned off by default

  • [#12408] 重构:将应用命令 media-play_pause 重命名为 media-play-pause

    ¥[#12408] refactor: rename app-command media-play_pause to media-play-pause

苹果系统

¥macOS

  • [#12093] 功能:工作区通知支持

    ¥[#12093] feat: workspace notifications support

  • [#12496] 功能:tray.setIgnoreDoubleClickEvents(ignore) 会忽略托盘双击事件。

    ¥[#12496] feat: tray.setIgnoreDoubleClickEvents(ignore) to ignore tray double click events.

  • [#12281] 功能:macOS 上的鼠标前进功能

    ¥[#12281] feat: mouse forward functionality on macOS

  • [#12714] 功能:屏幕锁定/解锁事件。

    ¥[#12714] feat: screen lock / unlock events

Windows

  • [#12879] 功能:添加了 DIP 与屏幕坐标之间的转换

    ¥[#12879] feat: added DIP to/from screen coordinate conversions

注意事项:运行此版本后切换到旧版本的 Electron 将需要你清除用户数据目录,以避免旧版本崩溃。你可以通过运行 console.log(app.getPath("userData")) 获取用户数据目录,或查看 docs 了解更多详细信息。

¥Nota Bene: Switching to an older version of Electron after running this version will require you to clear out your user data directory to avoid older versions crashing. You can get the user data directory by running console.log(app.getPath("userData")) or see docs for more details.

错误修复

¥Bug Fixes

  • [#13397] 修复:fs.statSyncNoException 抛出异常的问题

    ¥[#13397] fix: issue with fs.statSyncNoException throwing exceptions

  • [#13476, #13452] 修复:使用 jQuery 加载网站时崩溃

    ¥[#13476, #13452] fix: crash when loading site with jquery

  • [#14092] 修复:net::ClientSocketHandle 析构函数崩溃

    ¥[#14092] fix: crash in net::ClientSocketHandle destructor

  • [#14453] 修复:立即通知焦点变化,而不是在下一个 tick 通知

    ¥[#14453] fix: notify focus change right away rather not on next tick

苹果系统

¥MacOS

  • [#13220] 修复:在 <input file="type"> 打开文件对话框中允许选择 bundles 的问题

    ¥[#13220] fix: issue allowing bundles to be selected in <input file="type"> open file dialog

  • [#12404] 修复:使用异步对话框时阻塞主进程的问题

    ¥[#12404] fix: issue blocking main process when using async dialog

  • [#12043] 修复:上下文菜单点击回调

    ¥[#12043] fix: context menu click callback

  • [#12527] 修复:重用触控栏项目时发生事件泄漏

    ¥[#12527] fix: event leak on reuse of touchbar item

  • [#12352] 修复:托盘标题崩溃

    ¥[#12352] fix: tray title crash

  • [#12327] 修复:不可拖动区域

    ¥[#12327] fix: non-draggable regions

  • [#12809] 修复:防止菜单在打开时更新

    ¥[#12809] fix: to prevent menu update while it's open

  • [#13162] 修复:托盘图标边界不允许负值

    ¥[#13162] fix: tray icon bounds not allowing negative values

  • [#13085] 修复:托盘标题高亮时不反转

    ¥[#13085] fix: tray title not inverting when highlighted

  • [#12196] 修复:enable_run_as_node==false 时 Mac 版本

    ¥[#12196] fix: Mac build when enable_run_as_node==false

  • [#12157] 修复:解决了无框窗口与 Vibrancy 相关的其他问题

    ¥[#12157] fix: additional issues on frameless windows with vibrancy

  • [#13326] 修复:调用 app.removeAsDefaultProtocolClient 后将 mac 协议设置为 None

    ¥[#13326] fix: to set mac protocol to none after calling app.removeAsDefaultProtocolClient

  • [#13530] 修复:MAS 构建中私有 API 的使用不正确

    ¥[#13530] fix: incorrect usage of private APIs in MAS build

  • [#13517] 修复:tray.setContextMenu 崩溃

    ¥[#13517] fix: tray.setContextMenu crash

  • [#14205] 修复:即使设置了 defaultId,在对话框中按下 Esc 键也会关闭对话框。

    ¥[#14205] fix: pressing escape on a dialog now closes it even if defaultId is set

Linux

  • [#12507] 修复:BrowserWindow.focus() 用于屏幕外窗口

    ¥[#12507] fix: BrowserWindow.focus() for offscreen windows

其他说明

¥Other Notes

  • PDF 查看器目前无法运行,但正在改进中,很快就会恢复运行。

    ¥PDF Viewer is currently not working but is being worked on and will be functional once again soon

  • TextFieldButton API 处于实验阶段,因此默认关闭。

    ¥TextField and Button APIs are experimental and are therefore off by default

    • 可以通过 enable_view_api 构建标志启用它们

      ¥They can be enabled with the enable_view_api build flag

下一步计划

¥What's Next

Electron 团队将继续致力于定义我们的流程,以实现更快速、更顺畅的升级,我们力求最终与 Chromium、Node 和 V8 的开发节奏保持一致。

¥The Electron team continues to work on defining our processes for more rapid and smooth upgrades as we seek to ultimately maintain parity with the development cadences of Chromium, Node, and V8.

使用使用 GN 构建 Electron

· 5 min read

Electron 现在使用 GN 进行自我构建。以下是原因说明。

¥Electron now uses GN to build itself. Here's a discussion of why.


GYP 和 GN

¥GYP and GN

2013 年 Electron 首次发布时,Chromium 的构建配置是用 GYP("生成你的项目" 的缩写)编写的。

¥When Electron was first released in 2013, Chromium's build configuration was written with GYP, short for "Generate Your Projects".

2014 年,Chromium 项目引入了一个名为 GN(“Generate 忍者” 的缩写)的新构建配置工具。Chromium 的构建文件迁移到了 GN,GYP 也从源代码中移除。

¥In 2014, the Chromium project introduced a new build configuration tool called GN (short for "Generate Ninja") Chromium's build files were migrated to GN and GYP was removed from the source code.

Electron 一直以来都将主要的 Electron 代码libchromiumcontent 分开,libchromiumcontent 是 Electron 中封装 Chromium 'content' 子模块的部分。Electron 继续使用 GYP,而作为 Chromium 子集的 libchromiumcontent 也随着 Chromium 的迁移而切换到了 GN。

¥Electron has historically kept a separation between the main Electron code and libchromiumcontent, the part of Electron that wraps Chromium's 'content' submodule. Electron has carried on using GYP, while libchromiumcontent -- as a subset of Chromium -- switched to GN when Chromium did.

就像无法完全啮合的齿轮一样,使用这两种构建系统之间存在摩擦。维护兼容性很容易出错,因为编译器标志和 #defines 需要在 Chromium、Node、V8 和 Electron 之间保持同步。

¥Like gears that don't quite mesh, there was friction between using the two build systems. Maintaining compatibility was error-prone, from compiler flags and #defines that needed to be meticulously kept in sync between Chromium, Node, V8, and Electron.

为了解决这个问题,Electron 团队一直致力于将所有内容迁移到 GN。今天,用于从 Electron 中移除最后 GYP 代码的 commit 已发布到 master 分支。

¥To address this, the Electron team has been working on moving everything to GN. Today, the commit to remove the last of the GYP code from Electron was landed in master.

这对你意味着什么

¥What this means for you

如果你正在为 Electron 本身做贡献,那么从 master 或 4.0.0 版本检出并构建 Electron 的过程与 3.0.0 及更早版本截然不同。请参阅 GN 构建说明 获取详情。

¥If you're contributing to Electron itself, the process of checking out and building Electron from master or 4.0.0 is very different than it was in 3.0.0 and earlier. See the GN build instructions for details.

如果你正在使用 Electron 开发应用,你可能会注意到新版 Electron 4.0.0-nightly 中有一些细微的变化;但更有可能的是,Electron 在构建系统中的更改对你来说是完全透明的。

¥If you're developing an app with Electron, there are a few minor changes you might notice in the new Electron 4.0.0-nightly; but more than likely, Electron's change in build system will be totally transparent to you.

这对 Electron 意味着什么

¥What this means for Electron

GN 比 GYP 更先进,其文件更易于阅读和维护。此外,我们希望使用单一构建配置系统能够减少将 Electron 升级到新版本 Chromium 所需的工作量。

¥GN is faster than GYP and its files are more readable and maintainable. Moreover, we hope that using a single build configuration system will reduce the work required to upgrade Electron to new versions of Chromium.

  • 它已经极大地帮助了 Electron 4.0.0 的开发,因为 Chromium 67 取消了对 MSVC 的支持,并在 Windows 上切换到使用 Clang 构建。GN 版本直接从 Chromium 继承了所有编译器命令,因此我们免费获得了 Windows 上的 Clang 版本!

    ¥It's already helped development on Electron 4.0.0 substantially because Chromium 67 removed support for MSVC and switched to building with Clang on Windows. With the GN build, we inherit all the compiler commands from Chromium directly, so we got the Clang build on Windows for free!

  • 它还使 Electron 更容易在 Electron、Chromium 和 Node 之间统一构建使用 BoringSSL - 这在 之前存在问题 中是可以做到的。

    ¥It's also made it easier for Electron to use BoringSSL in a unified build across Electron, Chromium, and Node -- something that was problematic before.

WebPreferences 漏洞修复

· 5 min read

已发现一个远程代码执行漏洞,该漏洞会影响 Electron 版本(3.0.0-beta.6、2.0.7、1.8.7 和 1.7.15)中能够打开嵌套子窗口的应用。此漏洞已被分配 CVE 标识符 CVE-2018-15685

¥A remote code execution vulnerability has been discovered affecting apps with the ability to open nested child windows on Electron versions (3.0.0-beta.6, 2.0.7, 1.8.7, and 1.7.15). This vulnerability has been assigned the CVE identifier CVE-2018-15685.


受影响的平台

¥Affected Platforms

如果出现以下情况,你将会受到影响:

¥You are impacted if:

  1. 你嵌入了任何远程用户内容,即使是在沙盒中。

    ¥You embed any remote user content, even in a sandbox

  2. 你接受任何存在 XSS 漏洞的用户输入

    ¥You accept user input with any XSS vulnerabilities

细节

¥Details

如果任何用户代码在 iframe 中运行或创建 iframe,你将受到影响。考虑到存在 XSS 漏洞的可能性,可以假设大多数应用都容易受到此漏洞的影响。

¥You are impacted if any user code runs inside an iframe / can create an iframe. Given the possibility of an XSS vulnerability it can be assumed that most apps are vulnerable to this case.

如果你使用 nativeWindowOpen: truesandbox: true 选项。虽然此漏洞也需要应用中存在 XSS 漏洞才能造成,但如果你使用以下任一选项,仍应应用以下缓解措施之一。

¥You are also impacted if you open any of your windows with the nativeWindowOpen: true or sandbox: true option. Although this vulnerability also requires an XSS vulnerability to exist in your app, you should still apply one of the mitigations below if you use either of these options.

缓解措施

¥Mitigation

我们已发布 Electron 的新版本,其中包含针对此漏洞的修复:3.0.0-beta.72.0.81.8.81.7.16。我们敦促所有 Electron 开发者立即将其应用更新到最新的稳定版本。

¥We've published new versions of Electron which include fixes for this vulnerability: 3.0.0-beta.7, 2.0.8, 1.8.8, and 1.7.16. We urge all Electron developers to update their apps to the latest stable version immediately.

如果由于某种原因你无法升级 Electron 版本,你可以通过在 new-window 事件中为所有 webContents 事件统一调用 event.preventDefault() 来保护你的应用。如果你不使用 window.open 或任何子窗口,那么这对你的应用来说也是一个有效的缓解措施。

¥If for some reason you are unable to upgrade your Electron version, you can protect your app by blanket-calling event.preventDefault() on the new-window event for all webContents'. If you don't use window.open or any child windows at all then this is also a valid mitigation for your app.

mainWindow.webContents.on('new-window', (e) => e.preventDefault());

如果你依赖于子窗口创建孙窗口的功能,那么第三种缓解策略是在顶层窗口中使用以下代码:

¥If you rely on the ability of your child windows to make grandchild windows, then a third mitigation strategy is to use the following code on your top level window:

const enforceInheritance = (topWebContents) => {
const handle = (webContents) => {
webContents.on(
'new-window',
(event, url, frameName, disposition, options) => {
if (!options.webPreferences) {
options.webPreferences = {};
}
Object.assign(
options.webPreferences,
topWebContents.getLastWebPreferences(),
);
if (options.webContents) {
handle(options.webContents);
}
},
);
};
handle(topWebContents);
};

enforceInheritance(mainWindow.webContents);

此代码将强制将顶层窗口 webPreferences 手动应用于所有无限深的子窗口。

¥This code will manually enforce that the top level windows webPreferences is manually applied to all child windows infinitely deep.

更多信息

¥Further Information

此漏洞由 Contrast 安全Matt Austin 发现并负责任地报告给 Electron 项目。

¥This vulnerability was found and reported responsibly to the Electron project by Matt Austin of Contrast Security.

要了解有关保护 Electron 应用安全的最佳实践的更多信息,请参阅我们的 安全教程

¥To learn more about best practices for keeping your Electron apps secure, see our security tutorial.

如果你想报告 Electron 中的漏洞,请发送电子邮件至 security@electronjs.org

¥If you wish to report a vulnerability in Electron, email security@electronjs.org.

搜索

· 12 min read

Electron 网站推出了一个新的搜索引擎,可立即提供 API 文档、教程、与 Electron 相关的 npm 软件包等内容。

¥The Electron website has a new search engine that delivers instant results for API docs, tutorials, Electron-related npm packages, and more.

Electron Search Screenshot


学习像 Electron 这样的新技术或框架可能会令人望而生畏。一旦你度过了 quick-start 阶段,学习最佳实践、找到合适的 API 或发现能够帮助你构建理想应用的工具可能会很困难。我们希望 Electron 网站成为一个更好的工具,帮助你更快、更轻松地找到构建应用所需的资源。

¥Learning a new technology or framework like Electron can be intimidating. Once you get past the quick-start phase, it can be difficult to learn best practices, find the right APIs, or discover the tools that will help you build the app of your dreams. We want the Electron website to be a better tool for finding the resources you need to build apps faster and more easily.

访问 electronjs.org 上的任意页面,你都会在页面顶部找到新的搜索输入框。

¥Visit any page on electronjs.org and you'll find the new search input at the top of the page.

搜索引擎

¥The Search Engine

当我们最初着手为网站添加搜索功能时,我们使用 GraphQL 作为后端,推出了我们自己的搜索引擎。GraphQL 使用起来很有趣,搜索引擎也性能出色,但我们很快意识到,构建搜索引擎并非易事。像多词搜索和拼写错误检测这样的功能需要大量的工作才能正确实现。我们决定使用现有的搜索解决方案,而不是重新设计轮子:Algolia

¥When we first set about adding search to the website, we rolled our own search engine using GraphQL as a backend. GraphQL was fun to work with and the search engine was performant, but we quickly realized that building a search engine is not a trivial task. Things like multi-word search and typo detection require a lot of work to get right. Rather than reinventing the wheel, we decided to use an existing search solution: Algolia.

Algolia 是一项托管搜索服务,它迅速成为 React、Vue、Bootstrap、Yarn 和 其他 等热门开源项目的首选搜索引擎。

¥Algolia is a hosted search service that has quickly become the search engine of choice among popular open source projects like React, Vue, Bootstrap, Yarn, and many others.

以下是一些使 Algolia 非常适合 Electron 项目的功能:

¥Here are some of the features that made Algolia a good fit for the Electron project:

API 文档

¥API Docs

有时你知道自己想要实现什么,但却不知属性体该如何实现。Electron 拥有超过 750 个 API 方法、事件和属性。没有人能轻松记住所有这些,但计算机擅长这些。使用 Electron 的 JSON API 文档,我们将所有这些数据索引到 Algolia 中,现在你可以轻松找到所需的 API。

¥Sometimes you know what you want to accomplish, but you don't know exactly how to do it. Electron has over 750 API methods, events, and properties. No human can easily remember all of them, but computers are good at this stuff. Using Electron's JSON API docs, we indexed all of this data in Algolia, and now you can easily find the exact API you're looking for.

正在尝试调整窗口大小?搜索 resize 并直接跳转到你需要的方法。

¥Trying to resize a window? Search for resize and jump straight to the method you need.

教程

¥Tutorials

Electron 拥有不断增长的教程库来补充其 API 文档。现在,你可以更轻松地找到特定主题的教程,以及相关的 API 文档。

¥Electron has an ever-growing collection of tutorials to complement its API documentation. Now you can more easily find tutorials on a given topic, right alongside related API documentation.

正在寻找安全最佳实践?搜索 security

¥Looking for security best practices? Search for security.

npm 软件包

¥npm Packages

npm 仓库中目前有超过 70 万个软件包,要找到所需的软件包并非易事。为了更轻松地发现这些模块,我们创建了 electron-npm-packages,它是注册表中 3400 多个专为 Electron 使用而构建的模块的集合。

¥There are now over 700,000 packages in the npm registry and it's not always easy to find the one you need. To make it easier to discover these modules, we've created electron-npm-packages, a collection of the 3400+ modules in the registry that are built specifically for use with Electron.

Libraries.io 的团队创建了 SourceRank,这是一个基于代码、社区、文档和使用情况等指标组合对软件项目进行评分的系统。我们创建了一个 sourceranks 模块,其中包含 npm 注册表中每个模块的得分,并使用这些得分对软件包结果进行排序。

¥The folks at Libraries.io have created SourceRank, a system for scoring software projects based on a combination of metrics like code, community, documentation, and usage. We created a sourceranks module that includes the score of every module in the npm registry, and we use these scores to sort the package results.

想要 Electron 内置 IPC 模块的替代方案吗?搜索 is:package ipc

¥Want alternatives to Electron's built-in IPC modules? Search for is:package ipc.

Electron 应用

¥Electron Apps

这是 使用 Algolia 轻松索引数据 版本,所以我们添加了 electron/apps 版本中现有的应用列表。

¥It's easy to index data with Algolia, so we added the existing apps list from electron/apps.

尝试搜索 musichomebrew

¥Try a search for music or homebrew.

过滤结果

¥Filtering Results

如果你之前使用过 GitHub 的 代码搜索,你可能知道它像 extension:jsuser:defunkt 一样,使用冒号分隔的键值过滤器。我们认为这种过滤技术非常强大,因此我们在 Electron 的搜索中添加了 is: 关键字,可让你过滤结果以仅显示单一类型:

¥If you've used GitHub's code search before, you're probably aware of its colon-separated key-value filters like extension:js or user:defunkt. We think this filtering technique is pretty powerful, so we've added an is: keyword to Electron's search that lets you filter results to only show a single type:

键盘导航

¥Keyboard Navigation

人们喜欢键盘快捷键!新的搜索功能无需离开键盘即可使用:

¥People love keyboard shortcuts! The new search can be used without taking your fingers off the keyboard:

  • / 聚焦搜索输入

    ¥/ focuses the search input

  • esc 聚焦搜索输入并清除它

    ¥esc focuses the search input and clears it

  • down 移动到下一个结果

    ¥down moves to the next result

  • up 移动到上一个结果或搜索输入框

    ¥up moves to the previous result, or the search input

  • enter 打开结果

    ¥enter opens a result

我们还开源了支持这种键盘交互的 module。它设计用于 Algolia InstantSearch,但经过了通用化,以便与不同的搜索实现兼容。

¥We also open-sourced the module that enables this keyboard interaction. It's designed for use with Algolia InstantSearch, but is generalized to enable compatibility with different search implementations.

我们期待你的反馈

¥We want your feedback

如果你在使用新的搜索工具时遇到任何问题,我们很乐意听取你的意见!

¥If you encounter any issues with the new search tool, we want to hear about it!

提交反馈的最佳方式是在 GitHub 上的相应代码库中提交问题:

¥The best way to submit your feedback is by filing an issue on GitHub in the appropriate repository:

致谢

¥Thanks

特别感谢 Emily JordanVanessa Yuen 构建了这些新的搜索功能,感谢 Libraries.io 提供了 SourceRank 的评分,以及感谢 Algolia 团队帮助我们开始工作。🍹

¥Special thanks to Emily Jordan and Vanessa Yuen for building these new search capabilities, to Libraries.io for providing SourceRank scores, and to the team at Algolia for helping us get started. 🍹

国际化更新

· 7 min read

自新的国际化 Electron 网站 launch 以来,我们一直致力于让英语世界以外的开发者更容易获得 Electron 开发体验。

¥Ever since the launch of the new internationalized Electron website, we have been working hard to make the Electron development experience even more accessible to developers outside of the English speaking world.

现在,我们带来了一些激动人心的国际化更新!

¥So here we are with some exciting i18n updates!


🌐 语言切换

¥🌐 Language Toggle

你是否知道,许多阅读翻译文档的人经常将其与原始英文文档进行交叉引用?它们这样做是为了熟悉英文文档,并避免翻译过时或不准确,这是国际化文档的一个缺陷。

¥Did you know that many people who read translated documentation often cross reference that with the original English documentation? They do this to familiarize themselves with English docs, and to avoid outdated or inaccurate translations, which is one caveat of internationalized documentations.

Language toggle on Electron documentation

为了更轻松地交叉引用英文文档,我们最近发布了一项功能,允许你在英文和你正在浏览网站的任何语言之间无缝切换 Electron 文档的某个部分。只要你在网站上选择了非英语语言环境,语言切换就会显示。

¥To make cross-referencing to English docs easier, we recently shipped a feature that allows you to seamlessly toggle a section of the Electron documentation between English and whatever language you're viewing the website in. The language toggle will show up as long as you have a non-English locale selected on the website.

⚡ 快速访问翻译页面

¥⚡️ Quick Access to Translation Page

New Electron documentation footer in Japanese

阅读文档时,你是否注意到拼写错误或翻译错误?你不再需要登录 Crowdin、选择你的语言环境、找到你想要修复的文件等等。相反,你只需向下滚动到上述文档的底部,然后点击 "翻译此文档"(或你语言中的等效按钮)。瞧!你将直接进入 Crowdin 翻译页面。现在就施展你的翻译魔法吧!

¥Notice a typo or an incorrect translation while you're reading the documentation? You no longer have to log in to Crowdin, pick your locale, find the file you'd like the fix, etc etc. Instead, you can just scroll down to the bottom of the said doc, and click "Translate this doc" (or the equivalent in your language). Voila! You are brought straight to the Crowdin translation page. Now apply your translation magic!

📈 一些统计数据

¥📈 Some Statistics

自从我们公开 Electron 文档国际化工作以来,我们看到来自世界各地的 Electron 社区成员的翻译贡献大幅增长。迄今为止,我们已翻译了 1,719,029 个字符串,来自 1,066 位社区译者,涵盖 25 种语言。

¥Ever since we have publicized the Electron documentation i18n effort, we have seen huge growth in translation contributions from Electron community members from all around the world. To date, we have 1,719,029 strings translated, from 1,066 community translators, and in 25 languages.

Translation Forecast provided by Crowdin

以下是一个有趣的图表,显示了在保持现有进度(基于撰写本文时过去 14 天的项目活动)的情况下,将项目翻译成每种语言所需的大约时间。

¥Here is a fun graph showing the approximate amount of time needed to translate the project into each language if the existing tempo (based on the project activity during the last 14 days at the time of writing) is preserved.

📃 译者调查

¥📃 Translator Survey

我们衷心感谢每一位为改进 Electron 贡献时间的朋友们!❤️为了恰当地表彰我们翻译社区的辛勤工作,我们创建了一项调查,以收集一些关于我们翻译人员的信息(即他们的 Crowdin 和 Github 用户名之间的映射)。

¥We would like to give a huge ❤️ thank you ❤️ to everyone who has contributed their time to help improving Electron! In order to properly acknowledge the hard work of our translator community, we have created a survey to collect some information (namely the mapping between their Crowdin and Github usernames) about our translators.

如果你是我们优秀的翻译人员之一,请花几分钟时间填写以下表格:https://goo.gl/forms/b46sjdcHmlpV0GKT2

¥If you are one of our incredible translators, please take a few minutes to fill this out: https://goo.gl/forms/b46sjdcHmlpV0GKT2.

🙌 Node 的国际化工作

¥🙌 Node's Internationalization Effort

由于 Electron 国际化计划的成功,Node.js 决定效仿我们使用的模式来构建 他们改进的国际化工作 版本!🎉 Node.js 国际化倡议 现已发布并获得了巨大的发展势头,但你仍然可以阅读有关 此处 的早期提案及其背后的原因。

¥Because of the success of Electron's i18n initiative, Node.js decided to model their revamped i18n effort after the pattern we use as well! 🎉 The Node.js i18n initiative has now been launched and gained great momentum, but you can stil read about the early proposal and reasoning behind it here.

🔦 贡献指南

¥🔦 Contributing Guide

如果你有兴趣加入我们,让 Electron 更加国际化,我们有一个方便易用的 贡献指南 来帮助你入门。祝你国际化愉快!📚

¥If you're interested in joining our effort to make Electron more international friendly, we have a handy-dandy contributing guide to help you get started. Happy internationalizing! 📚

Electron 2.0.0

· 12 min read

经过四个多月的开发、八个 Beta 版本发布以及来自众多应用的分阶段部署的全球测试,Electron 2.0.0 现已从 electronjs.org 开始提供。

¥After more than four months of development, eight beta releases, and worldwide testing from many apps' staged rollouts, the release of Electron 2.0.0 is now available from electronjs.org.


发布流程

¥Release Process

从 2.0.0 开始,Electron 的版本将遵循 语义版本控制 选项。这意味着主要版本号的更新会更频繁,并且通常是 Chromium 的重大更新。补丁版本应该更稳定,因为它们只包含高优先级的错误修复。

¥Starting with 2.0.0, Electron's releases will follow semantic versioning. This means the major version will bump more often and will usually be a major update to Chromium. Patch releases should be more stable because they will contain only high-priority bug fixes.

Electron 2.0.0 也代表了 Electron 在主要版本发布前的稳定性改进。多个大型 Electron 应用已分阶段部署 2.0.0 测试版,为 Electron 的测试版系列提供了最佳的反馈循环。

¥Electron 2.0.0 also represents an improvement to how Electron is stabilized before a major release. Several large scale Electron apps have included 2.0.0 betas in staged rollouts, providing the best feedback loop Electron's ever had for a beta series.

变更/新功能

¥Changes / New Features

  • Electron 工具链的几个重要部分发生了重大变化,包括 Chrome 61、Node 8.9.3、V8 6.1.534.41、Linux 上的 GTK+ 3、更新的拼写检查器和 Squirrel。

    ¥Major bumps to several important parts of Electron's toolchain, including Chrome 61, Node 8.9.3, V8 6.1.534.41, GTK+ 3 on Linux, updated spellchecker, and Squirrel.

  • 应用内购买 现在支持 MacOS。#11292

    ¥In-app purchases are now supported on MacOS. #11292

  • 用于加载文件的新 API。#11565

    ¥New API for loading files. #11565

  • 用于启用/禁用窗口的新 API。#11832

    ¥New API to enable/disable a window. #11832

  • 新 API app.setLocale()。#11469

    ¥New API app.setLocale(). #11469

  • 新增 IPC 消息日志记录支持。#11880

    ¥New support for logging IPC messages. #11880

  • 新的菜单事件。#11754

    ¥New menu events. #11754

  • 向 powerMonitor 添加 shutdown 事件。#11417

    ¥Add a shutdown event to powerMonitor. #11417

  • 添加 affinity 选项,用于将多个 BrowserWindows 聚合到单个进程中。#11501

    ¥Add affinity option for gathering several BrowserWindows into a single process. #11501

  • 为 saveDialog 添加列出可用扩展名的功能。#11873

    ¥Add the ability for saveDialog to list available extensions. #11873

  • 支持额外的通知操作 #11647

    ¥Support for additional notification actions #11647

  • 设置 macOS 通知关闭按钮标题的功能。#11654

    ¥The ability to set macOS notification close button title. #11654

  • 为 menu.popup(window, callback) 添加条件语句。

    ¥Add conditional for menu.popup(window, callback)

  • 触控栏项目的内存优化。#12527

    ¥Memory improvements in touchbar items. #12527

  • 改进了安全建议清单。

    ¥Improved security recommendation checklist.

  • 添加 App-Scoped Security 作用域书签。#11711

    ¥Add App-Scoped Security scoped bookmarks. #11711

  • 添加了在渲染器进程中设置任意参数的功能。#11850

    ¥Add ability to set arbitrary arguments in a renderer process. #11850

  • 为格式选择器添加附件视图。#11873

    ¥Add accessory view for format picker. #11873

  • 修复了网络委托竞争条件问题。#12053

    ¥Fixed network delegate race condition. #12053

  • 放弃对 Linux 上 mips64el 架构的支持。Electron 需要 C++14 工具链,但在发布时该架构尚不支持该工具链。我们希望将来能够重新提供支持。

    ¥Drop support for the mips64el arch on Linux. Electron requires the C++14 toolchain, which was not available for that arch at the time of the release. We hope to re-add support in the future.

重大 API 更改

¥Breaking API changes

  • 移除 已弃用的 API,包括:

    ¥Removed deprecated APIs, including:

    • 更改了 menu.popup 签名。#11968

      ¥Changed menu.popup signature. #11968

    • 移除了已弃用的 crashReporter.setExtraParameter#11972

      ¥Removed deprecated crashReporter.setExtraParameter #11972

    • 移除了已弃用的 webContents.setZoomLevelLimitswebFrame.setZoomLevelLimits#11974

      ¥Removed deprecated webContents.setZoomLevelLimits and webFrame.setZoomLevelLimits. #11974

    • 移除了已弃用的 clipboard 方法。#11973

      ¥Removed deprecated clipboard methods. #11973

    • 移除了对 tray.setHighlightMode 布尔参数的支持。#11981

      ¥Removed support for boolean parameters for tray.setHighlightMode. #11981

错误修复

¥Bug Fixes

  • 已更改以确保 webContents.isOffscreen() 始终可用。#12531

    ¥Changed to make sure webContents.isOffscreen() is always available. #12531

  • 修复了 DevTools 取消停靠并获得焦点时 BrowserWindow.getFocusedWindow() 的问题。#12554

    ¥Fixed BrowserWindow.getFocusedWindow() when DevTools is undocked and focused. #12554

  • 修复了如果预加载路径包含特殊字符,则在沙盒渲染中预加载无法加载的问题。#12643

    ¥Fixed preload not loading in sandboxed render if preload path contains special chars. #12643

  • 根据文档更正 allowRunningInsecureContent 的默认值。#12629

    ¥Correct the default of allowRunningInsecureContent as per docs. #12629

  • 修复了 nativeImage 的透明度问题。#12683

    ¥Fixed transparency on nativeImage. #12683

  • 修复了 Menu.buildFromTemplate 的问题。#12703

    ¥Fixed issue with Menu.buildFromTemplate. #12703

  • 已确认 menu.popup 选项是对象。#12330

    ¥Confirmed menu.popup options are objects. #12330

  • 移除了新进程创建和上下文释放之间的竞争条件。#12361

    ¥Removed a race condition between new process creation and context release. #12361

  • 更改浏览器视图时更新可拖动区域。#12370

    ¥Update draggable regions when changing BrowserView. #12370

  • 修复了菜单栏切换按钮在焦点处检测 ALT 键的问题。#12235

    ¥Fixed menubar toggle alt key detection on focus. #12235

  • 修复了 Web 视图中不正确的警告。#12236

    ¥Fixed incorrect warnings in webviews. #12236

  • 修复了 'show' 选项从父窗口继承的问题。#122444

    ¥Fixed inheritance of 'show' option from parent windows. #122444

  • 确保 getLastCrashReport() 确实是最后一个崩溃报告。#12255

    ¥Ensure that getLastCrashReport() is actually the last crash report. #12255

  • 修复了网络共享路径的依赖问题。#12287

    ¥Fixed require on network share path. #12287

  • 修复了上下文菜单点击回调问题。#12170

    ¥Fixed context menu click callback. #12170

  • 修复了弹出菜单的位置问题。#12181

    ¥Fixed popup menu position. #12181

  • 改进了 libuv 循环清理。#11465

    ¥Improved libuv loop cleanup. #11465

  • 修复了 hexColorDWORDToRGBA 的透明颜色问题。#11557

    ¥Fixed hexColorDWORDToRGBA for transparent colors. #11557

  • 修复了 getWebPreferences API 的空指针取消引用问题。#12245

    ¥Fixed null pointer dereference with getWebPreferences api. #12245

  • 修复了菜单委托中的循环引用问题。#11967

    ¥Fixed a cyclic reference in menu delegate. #11967

  • 修复了 net.request 的协议过滤问题。#11657

    ¥Fixed protocol filtering of net.request. #11657

  • WebFrame.setVisualZoomLevelLimits 现在设置用户代理缩放限制 #12510

    ¥WebFrame.setVisualZoomLevelLimits now sets user-agent scale constraints #12510

  • 为 WebView 选项设置合适的默认值。#12292

    ¥Set appropriate defaults for webview options. #12292

  • 增强了活力支持。#12157 #12171 #11886

    ¥Improved vibrancy support. #12157 #12171 #11886

  • 修复了单例固件中的计时问题。

    ¥Fixed timing issue in singleton fixture.

  • 修复了 NotifierSupportsActions() 中损坏的生产缓存问题。

    ¥Fixed broken production cache in NotifierSupportsActions()

  • 使 MenuItem 角色兼容驼峰命名。#11532

    ¥Made MenuItem roles camelCase-compatible. #11532

  • 改进了触控栏更新。#11812#11761

    ¥Improved touch bar updates. #11812, #11761.

  • 移除了多余的菜单分隔符。#11827

    ¥Removed extra menu separators. #11827

  • 修复了蓝牙选择器的错误。关闭 #11399

    ¥Fixed Bluetooth chooser bug. Closes #11399.

  • 修复了 macOS 全屏切换菜单项标签的问题。#11633

    ¥Fixed macos Full Screen Toggle menu item label. #11633

  • 改进了窗口停用时工具提示的隐藏。#11644

    ¥Improved tooltip hiding when a window is deactivated. #11644

  • 迁移已弃用的 web-view 方法。#11798

    ¥Migrated deprecated web-view method. #11798

  • 修复了关闭从浏览器视图打开的窗口的问题。#11799

    ¥Fixed closing a window opened from a browserview. #11799

  • 修复了蓝牙选择器的错误。#11492

    ¥Fixed Bluetooth chooser bug. #11492

  • 更新了 app.getFileIcon API,使其使用任务调度程序。#11595

    ¥Updated to use task scheduler for app.getFileIcon API. #11595

  • 更改为即使在离屏渲染时也会触发 console-message 事件。#11921

    ¥Changed to fire console-message event even when rendering offscreen. #11921

  • 修复了使用 WebContents.downloadURL 从自定义协议下载的问题。#11804

    ¥Fixed downloading from custom protocols using WebContents.downloadURL. #11804

  • 修复了透明窗口在 devtools 分离时失去透明度的问题。#11956

    ¥Fixed transparent windows losing transparency when devtools detaches. #11956

  • 修复了 Electron 应用取消重启或关机的问题。#11625

    ¥Fixed Electron apps canceling restart or shutdown. #11625

苹果系统

¥macOS

  • 修复了触控栏项目重用时事件泄漏的问题。#12624

    ¥Fixed event leak on reuse of touchbar item. #12624

  • 修复了暗黑模式下托盘高亮的问题。#12398

    ¥Fixed tray highlight in darkmode. #12398

  • 修复了异步对话框阻塞主进程的问题。#12407

    ¥Fixed blocking main process for async dialog. #12407

  • 修复了 setTitle 托盘崩溃问题。#12356

    ¥Fixed setTitle tray crash. #12356

  • 修复了设置停靠菜单时崩溃的问题。#12087

    ¥Fixed crash when setting dock menu. #12087

Linux

Windows

  • 添加了 Visual Studio 2017 支持。#11656

    ¥Added Visual Studio 2017 support. #11656

  • 修复了将异常传递给系统崩溃处理程序的问题。#12259

    ¥Fixed passing of exception to the system crash handler. #12259

  • 修复了最小化窗口隐藏工具提示的问题。#11644

    ¥Fixed hiding tooltip from minimized window. #11644

  • 修复了 desktopCapturer 以截取正确的屏幕。#11664

    ¥Fixed desktopCapturer to capture the correct screen. #11664

  • 修复了 disableHardwareAcceleration 的透明度问题。#11704

    ¥Fixed disableHardwareAcceleration with transparency. #11704

下一步计划

¥What's Next

Electron 团队正在努力支持 Chromium、Node 和 v8 的新版本。3.0.0-beta.1 即将发布!

¥The Electron team is hard at work to support newer versions of Chromium, Node, and v8. Expect 3.0.0-beta.1 soon!

开源应用更轻松的自动更新

· 6 min read

今天,我们发布了免费、开源、托管的 更新 Web 服务 及其配套 npm 包,以便轻松实现开源 Electron 应用的自动更新。这是让应用开发者更少考虑部署,更多地关注为用户开发高质量体验的一步。

¥Today we're releasing a free, open-source, hosted updates webservice and companion npm package to enable easy automatic updates for open-source Electron apps. This is a step toward empowering app developers to think less about deployment and more about developing high-quality experiences for their users.


让生活更轻松

¥Making life easier

Electron 拥有 autoUpdater API,使应用能够使用来自远程端点的元数据来检查更新、在后台下载并自动安装。

¥Electron has an autoUpdater API that gives apps the ability to consume metadata from a remote endpoint to check for updates, download them in the background, and install them automatically.

对于许多 Electron 应用开发者来说,启用这些更新一直是部署过程中繁琐的一步,因为它需要部署和维护一个 Web 服务器来提供应用版本历史元数据。

¥Enabling these updates has been a cumbersome step in the deployment process for many Electron app developers because it requires a web server to be deployed and maintained just to serve app version history metadata.

今天,我们宣布推出一款用于自动应用更新的全新嵌入式解决方案。如果你的 Electron 应用位于公共 GitHub 仓库中,并且你使用 GitHub Releases 发布构建版本,则可以使用此服务向用户提供持续的应用更新。

¥Today we are announcing a new drop-in solution for automatic app updates. If your Electron app is in a public GitHub repository and you're using GitHub Releases to publish builds, you can use this service to deliver continuous app updates to your users.

使用新模块

¥Using the new module

为了最大限度地减少你的配置工作,我们创建了 update-electron-app,这是一个与新的 update.electronjs.org Web 服务集成的 npm 模块。

¥To minimize configuration on your part, we've created update-electron-app, an npm module which integrates with the new update.electronjs.org webservice.

安装模块:

¥Install the module:

npm install update-electron-app

可在应用的 主进程 中的任何位置调用:

¥Call it from anywhere in your app's main process:

require('update-electron-app')();

就是这样!该模块将在应用启动时检查更新,然后每十分钟检查一次。当发现更新时,它会在后台自动下载,并在更新准备就绪时显示一个对话框。

¥That's it! The module will check for updates at app startup, then every ten minutes. When an update is found it will download automatically in the background, and a dialog will be displayed when the update is ready.

迁移现有的应用

¥Migrating existing apps

已经使用 Electron autoUpdater API 的应用也可以使用此服务。为此,你可以使用 自定义 update-electron-app 模块或 直接与 update.electronjs.org 集成 模块。

¥Apps already using Electron's autoUpdater API can use this service too. To do so, you can customize the update-electron-app module or integrate directly with update.electronjs.org.

替代方案

¥Alternatives

如果你使用 electron-builder 打包应用,可以使用其内置的更新程序。详情请参阅 electron.build/auto-update

¥If you're using electron-builder to package your app, you can use its built-in updater. For details, see electron.build/auto-update.

如果你的应用是私有的,则可能需要运行自己的更新服务器。有很多开源工具可以实现这一点,包括 Zeit 的 Hazel 和 Atlassian 的 。请参阅 部署更新服务器 教程了解更多信息。

¥If your app is private, you may need to run your own update server. There are a number of open-source tools for this, including Zeit's Hazel and Atlassian's Nucleus. See the Deploying an Update Server tutorial for more info.

致谢

¥Thanks

感谢 Julian Gruber 帮助设计和构建这个简单且可扩展的 Web 服务。感谢 Zeit 的朋友们开源了 Hazel 服务,我们从中汲取了设计灵感。感谢 Samuel Attard 的代码审查。感谢 Electron 社区帮助测试这项服务。

¥Thanks to Julian Gruber for helping design and build this simple and scalable web service. Thanks to the folks at Zeit for their open-source Hazel service, from which we drew design inspiration. Thanks to Samuel Attard for the code reviews. Thanks to the Electron community for helping test this service.

🌲 祝 Electron 应用未来长青!

¥🌲 Here's to an evergreen future for Electron apps!