Skip to main content

Electron 36.0.0

· 9 min read

Electron 36.0.0 已发布!此更新包含对 Chromium 136、V8 13.6 和 Node 22.14.0 的升级。

¥Electron 36.0.0 has been released! It includes upgrades to Chromium 136, V8 13.6, and Node 22.14.0.


Electron 团队非常高兴地宣布 Electron 36.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息。

¥The Electron team is excited to announce the release of Electron 36.0.0! You can install it with npm via npm install electron@latest or download it from our releases website. Continue reading for details about this release.

如果你有任何反馈,请在 BlueskyMastodon 上与我们分享,或加入我们的社区 Discord!可以在 Electron 的 问题跟踪器 中报告错误和功能请求。

¥If you have any feedback, please share it with us on Bluesky or Mastodon, or join our community Discord! Bugs and feature requests can be reported in Electron's issue tracker.

显著变化

¥Notable Changes

写作工具支持

¥Writing Tools Support

在 Electron 36 中,你可以在上下文菜单中启用 macOS 系统级功能,例如写作工具(拼写和语法)、自动填充和服务菜单项。为此,请将 Web 框架主 实例传递给 menu.popup()frame 参数。

¥In Electron 36, you can enable macOS system-level features like Writing Tools (spelling and grammar), Autofill, and Services menu items in your context menus. To do so, pass a WebFrameMain instance into the frame parameter for menu.popup().

import { BrowserWindow, Menu, WebFrameMain } from 'electron';

const currentWindow = BrowserWindow.getFocusedWindow();
const focusedFrame = currentWindow.webContents.focusedFrame;
const menu = Menu.buildFromTemplate([{ label: 'Copy', role: 'copy' }]);

menu.popup({
window: currentWindow,
frame: focusedFrame,
});

技术栈变更

¥Stack Changes

Electron 36 将 Chromium 从 134.0.6998.23 升级到 136.0.7103.48,并将 V8 从 13.5 升级到 13.6

¥Electron 36 upgrades Chromium from 134.0.6998.23 to 136.0.7103.48, and V8 from 13.5 to 13.6.

新功能和改进

¥New Features and Improvements

  • 添加 BrowserWindow.isSnapped() 以指示给定窗口是否已通过 Windows 上的 Snap 排列。#46226

    ¥Added BrowserWindow.isSnapped() to indicate whether a given window has been arranged via Snap on Windows. #46226

  • 添加 WebContents.focusedFrame 以获取焦点框架。

    ¥Added WebContents.focusedFrame to get the focused frame.

  • 修复了 WebContents.opener 以指定潜在的 null 类型。#45667

    ¥Fixed WebContents.opener to specify potential null type. #45667

  • 添加 ffmpeg.dll 以延迟加载配置。#461733435 中也支持)

    ¥Added ffmpeg.dll to delay load configuration. #46173 (Also in 34, 35)

  • 添加 nativeTheme.shouldUseDarkColorsForSystemIntegratedUI 以区分系统主题和应用主题。#4659835 中也包含)

    ¥Added nativeTheme.shouldUseDarkColorsForSystemIntegratedUI to distinguish system and app theme. #46598 (Also in 35)

  • webRequest 过滤器中添加了 excludeUrls,并弃用了 urls 属性中空数组的使用。#4469235 中也包含)

    ¥Added excludeUrls to webRequest filter and deprecated the use of empty arrays in urls property. #44692 (Also in 35)

  • 通过 menu.popup 中新的 frame 选项,在上下文菜单中添加了对自动填充、写作工具和服务 macOS 级菜单项的支持。#46350

    ¥Added support for Autofill, Writing Tools and Services macOS level menu items in context menus via the new frame option in menu.popup. #46350

  • 添加了对 Linux 上 system-context-menu 的支持。#46399

    ¥Added support for system-context-menu on Linux. #46399

  • 改进了 Windows 上的 ASAR 完整性检查。#46537

    ¥Improved ASAR integrity checks on Windows. #46537

  • 改进了在 macOS 上不请求缩略图时 desktopCapturer.getSources 的性能。#462513435 中也支持)

    ¥Improved performance of desktopCapturer.getSources when not requesting thumbnails on macOS. #46251 (Also in 34, 35)

  • 移除了使用共享纹理 OSR 时 240 FPS 的限制。#4566935 中也存在)

    ¥Removed 240 FPS limit when use shared texture OSR. #45669 (Also in 35)

重大变化

¥Breaking Changes

已弃用:NativeImage.getBitmap()

¥Deprecated: NativeImage.getBitmap()

NativeImage.getBitmap() 函数现已弃用,并记录为 NativeImage.toBitmap() 的别名。这两个函数都返回一个新分配的位图副本,并且功能相同。

¥The NativeImage.getBitmap() function is now deprecated and documented as an alias for NativeImage.toBitmap(). The two functions both return a newly-allocated copy of the bitmap and are functionally equivalent.

已弃用:session 上的扩展方法和事件

¥Deprecated: Extension methods and events on session

session.loadExtensionsession.removeExtensionsession.getExtensionsession.getAllExtensions 以及事件 extension-loadedextension-unloadedextension-ready 均已移至新的 Extensions 对象,可通过 session.extensions 实例属性访问。

¥session.loadExtension, session.removeExtension, session.getExtension, session.getAllExtensions, and the events extension-loaded, extension-unloaded, and extension-ready have all moved to the new Extensions object accessible via the session.extensions instance property.

删除:session.clearStorageData(options) 中的 quota 类型 syncable

¥Removed: quota type syncable in session.clearStorageData(options)

调用 session.clearStorageData(options) 时,options.quota 类型 syncable 不再受支持,因为它已从上游 Chromium 升级为 removed

¥When calling session.clearStorageData(options), the options.quota type syncable is no longer supported because it has been removed from upstream Chromium.

已弃用:session.clearStorageData(options) 中的 quota 属性

¥Deprecated: quota property in session.clearStorageData(options)

调用 Session.clearStorageData(options) 时,options.quota 属性已被弃用。由于 syncable 类型已被删除,只剩下 'temporary' 类型,因此无需指定。

¥When calling Session.clearStorageData(options), the options.quota property is deprecated. Since the syncable type was removed, there is only type left -- 'temporary' -- so specifying it is unnecessary.

行为改变:在 GNOME 上运行时,GTK 4 是默认设置

¥Behavior Changed: GTK 4 is the default when running on GNOME

上游变更 之后,GTK 4 现在是 GNOME 运行时的默认设置。

¥After an upstream change, GTK 4 is now the default when running on GNOME.

在极少数情况下,这可能会导致某些应用或配置发生 error 错误,并显示以下消息:

¥In rare cases, this may cause some applications or configurations to error with the following message:

Gtk-ERROR **: 11:30:38.382: GTK 2/3 symbols detected. Using GTK 2/3 and GTK 4 in the same process is not supported

受影响的用户可以通过指定 gtk-version 命令行标志来解决这个问题:

¥Affected users can work around this by specifying the gtk-version command-line flag:

$ electron --gtk-version=3   # or --gtk-version=2

app.commandLine.appendSwitch 函数也可以实现同样的功能。

¥The same can be done with the app.commandLine.appendSwitch function.

行为改变:app.commandLine

¥Behavior Changed: app.commandLine

app.commandLine 会将大写的开关和参数转换为小写。

¥app.commandLine will convert uppercases switches and arguments to lowercase.

app.commandLine 仅用于处理 Chromium 开关(不区分大小写),通过 app.commandLine 传递的开关不会传递给任何子进程。

¥app.commandLine was only meant to handle Chromium switches (which aren't case-sensitive) and switches passed via app.commandLine will not be passed down to any of the child processes.

如果你使用 app.commandLine 解析特定于应用的命令行参数,则应通过 process.argv 执行此操作。

¥If you were using app.commandLine to parse app-specific command line arguments, you should do this via process.argv.

33.x.y 停止支持

¥End of Support for 33.x.y

Electron 33.x.y 已根据项目的 支持政策 达到支持终止状态。建议开发者和应用升级到较新版本的 Electron。

¥Electron 33.x.y has reached end-of-support as per the project's support policy. Developers and applications are encouraged to upgrade to a newer version of Electron.

E36 (2025 年 4 月)E37 (2025 年 6 月)E38 (2025 年 8 月)
36.x.y37.x.y38.x.y
35.x.y36.x.y37.x.y
34.x.y35.x.y36.x.y

下一步计划

¥What's Next

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。

¥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.

你可以找到 Electron 公开时间线

¥You can find Electron's public timeline here.

有关未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥More information about future changes can be found on the Planned Breaking Changes page.

Electron 35.0.0

· 11 min read

Electron 35.0.0 已发布!此更新包含对 Chromium 134.0.6998.44、V8 13.5 和 Node 22.14.0 的升级。

¥Electron 35.0.0 has been released! It includes upgrades to Chromium 134.0.6998.44, V8 13.5, and Node 22.14.0.


Electron 团队非常高兴地宣布 Electron 35.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息。

¥The Electron team is excited to announce the release of Electron 35.0.0! You can install it with npm via npm install electron@latest or download it from our releases website. Continue reading for details about this release.

如果你有任何反馈,请在 BlueskyMastodon 上与我们分享,或加入我们的社区 Discord!可以在 Electron 的 问题跟踪器 中报告错误和功能请求。

¥If you have any feedback, please share it with us on Bluesky or Mastodon, or join our community Discord! Bugs and feature requests can be reported in Electron's issue tracker.

显著变化

¥Notable Changes

Service Worker 预加载脚本,用于改进扩展支持

¥Service Worker Preload Scripts for Improved Extensions Support

最初由 @samuelmaddockRFC #8 中提出的 Electron 35 添加了将预加载脚本附加到 服务工作进程 的功能。由于 Chrome 的 Manifest V3 Extensions 将大量工作路由到 扩展服务工作者,此功能填补了 Electron 对现代 Chrome 扩展程序支持的空白。

¥Originally proposed in RFC #8 by @samuelmaddock, Electron 35 adds the ability to attach a preload script to Service Workers. With Chrome's Manifest V3 Extensions routing a lot of work through extension service workers, this feature fills in a gap in Electron's support for modern Chrome extensions.

在会话级别以编程方式注册预加载脚本时,现在可以使用 ses.registerPreloadScript(script) API 将其专门应用于 Service Worker 上下文。

¥When registering a preload script programmatically at the Session level, you can now specifically apply it to Service Worker contexts with the ses.registerPreloadScript(script) API.

Main Process
// Add our preload realm script to the session.
session.defaultSession.registerPreloadScript({
// Our script should only run in service worker preload realms.
type: 'service-worker',
// The absolute path to the script.
script: path.join(__dirname, 'extension-sw-preload.js'),
});

此外,现在可以通过 ServiceWorkerMain.ipc 类在 Service Worker 及其附加的预加载脚本之间进行进程间通信 (IPC)。预加载脚本仍将使用 ipcRenderer 模块与其 Service Worker 进行通信。更多详情请参阅原始 RFC。

¥Furthermore, IPC is now available between Service Workers and their attached preload scripts via the ServiceWorkerMain.ipc class. The preload script will still use the ipcRenderer module to communicate with its Service Worker. See the original RFC for more details.

此功能之前有许多其他更改为其奠定了基础:

¥This feature was preceded by many other changes that laid the groundwork for it:

  • #45329 重新设计了 Session 模块的预加载 API,以支持注册和注销单个预加载脚本。

    ¥#45329 redesigned the Session module's preload APIs to support registering and unregistering individual preload scripts.

  • #45229 添加了实验性的 contextBridge.executeInMainWorld(executionScript) 脚本,用于通过上下文桥接器在主世界中执行 JavaScript。

    ¥#45229 added the experimental contextBridge.executeInMainWorld(executionScript) script to evaluate JavaScript in the main world over the context bridge.

  • #45341 添加了 ServiceWorkerMain 类,用于在主进程中与 Service Worker 交互。

    ¥#45341 added the ServiceWorkerMain class to interact with Service Workers in the main process.

技术栈变更

¥Stack Changes

Electron 35 将 Chromium 从 132.0.6834.83 升级到 134.0.6998.44,将 Node 从 20.18.1 升级到 22.14.0,将 V8 从 13.2 升级到 13.5

¥Electron 35 upgrades Chromium from 132.0.6834.83 to 134.0.6998.44, Node from 20.18.1 to 22.14.0, and V8 from 13.2 to 13.5.

新功能

¥New Features

  • Info.plist 中添加了 NSPrefersDisplaySafeAreaCompatibilityMode = false 以从应用选项中移除 "缩放以适应内置摄像头。"。#45357 v34.1.0 中也包含)

    ¥Added NSPrefersDisplaySafeAreaCompatibilityMode = false to Info.plist to remove "Scale to fit below built-in camera." from app options. #45357 (Also in v34.1.0)

  • 添加了 ServiceWorkerMain 类,用于与主进程中的服务工作线程交互。#45341

    ¥Added ServiceWorkerMain class to interact with service workers in the main process. #45341

    • ServiceWorkers 上添加了 running-status-changed 事件,用于指示服务工作线程的运行状态何时发生变化。

      ¥Added running-status-changed event on ServiceWorkers to indicate when a service worker's running status has changed.

    • ServiceWorkers 上添加了 startWorkerForScope,用于启动可能之前已停止的工作器。

      ¥Added startWorkerForScope on ServiceWorkers to start a worker that may have been previously stopped.

  • 添加了实验性 contextBridge.executeInMainWorld,以便安全地跨世界边界执行代码。#45330

    ¥Added experimental contextBridge.executeInMainWorld to safely execute code across world boundaries. #45330

  • 'console-message' 事件中添加了 frame#43617

    ¥Added frame to 'console-message' event. #43617

  • 在 Windows 上添加了 query-session-end 事件并改进了 session-end 事件。#44598

    ¥Added query-session-end event and improved session-end events on Windows. #44598

  • 添加了 view.getVisible()#45409

    ¥Added view.getVisible(). #45409

  • 添加了允许恢复导航历史记录的 webContents.navigationHistory.restore(index, entries) API。#45583

    ¥Added webContents.navigationHistory.restore(index, entries) API that allows restoration of navigation history. #45583

  • BrowserWindow.setVibrancy 添加了可选动画参数。#35987

    ¥Added optional animation parameter to BrowserWindow.setVibrancy. #35987

  • document.executeCommand("paste") 添加了权限支持。#45471 v34.1.0 中也包含)

    ¥Added permission support for document.executeCommand("paste"). #45471 (Also in v34.1.0)

  • 添加了对 Windows 上 roundedCorners BrowserWindow 构造函数选项的支持。#45740 v34.3.0 中也包含)

    ¥Added support for roundedCorners BrowserWindow constructor option on Windows. #45740 (Also in v34.3.0)

  • 添加了对服务工作线程预加载脚本的支持。#45408

    ¥Added support for service worker preload scripts. #45408

  • 支持 Portal 的 globalShortcuts。Electron 必须与 --enable-features=GlobalShortcutsPortal 一起运行才能使该功能正常运行。#45297

    ¥Support Portal's globalShortcuts. Electron must be run with --enable-features=GlobalShortcutsPortal in order to have the feature working. #45297

重大变化

¥Breaking Changes

删除:PrinterInfo 上的 isDefaultstatus 属性

¥Removed: isDefault and status properties on PrinterInfo

这些属性已从 PrinterInfo 对象中移除,因为它们已从上游 Chromium 中移除。

¥These properties have been removed from the PrinterInfo object because they have been removed from upstream Chromium.

已弃用:session.serviceWorkers 上的 getFromVersionID

¥Deprecated: getFromVersionID on session.serviceWorkers

session.serviceWorkers.fromVersionID(versionId) API 已被弃用,取而代之的是 session.serviceWorkers.getInfoFromVersionID(versionId)。通过引入 session.serviceWorkers.getWorkerFromVersionID(versionId) API,这已更改,以便更清楚地返回哪个对象。

¥The session.serviceWorkers.fromVersionID(versionId) API has been deprecated in favor of session.serviceWorkers.getInfoFromVersionID(versionId). This was changed to make it more clear which object is returned with the introduction of the session.serviceWorkers.getWorkerFromVersionID(versionId) API.

// Deprecated
session.serviceWorkers.fromVersionID(versionId);

// Replace with
session.serviceWorkers.getInfoFromVersionID(versionId);

已弃用:Session 上的 setPreloadsgetPreloads

¥Deprecated: setPreloads, getPreloads on Session

registerPreloadScriptunregisterPreloadScriptgetPreloadScripts 是作为弃用方法的替代品引入的。这些新 API 允许第三方库注册预加载脚本,而无需替换现有脚本。此外,新的 type 选项允许除 frame 之外的其他预加载目标。

¥registerPreloadScript, unregisterPreloadScript, and getPreloadScripts are introduced as a replacement for the deprecated methods. These new APIs allow third-party libraries to register preload scripts without replacing existing scripts. Also, the new type option allows for additional preload targets beyond frame.

// Deprecated
session.setPreloads([path.join(__dirname, 'preload.js')]);

// Replace with:
session.registerPreloadScript({
type: 'frame',
id: 'app-preload',
filePath: path.join(__dirname, 'preload.js'),
});

已弃用:WebContentsconsole-message 事件中的 levelmessagelinesourceId 参数

¥Deprecated: level, message, line, and sourceId arguments in console-message event on WebContents

WebContents 上的 console-message 事件已更新,以提供有关 Event 参数的详细信息。

¥The console-message event on WebContents has been updated to provide details on the Event argument.

// Deprecated
webContents.on(
'console-message',
(event, level, message, line, sourceId) => {},
);

// Replace with:
webContents.on(
'console-message',
({ level, message, lineNumber, sourceId, frame }) => {},
);

此外,level 现在是一个字符串,可能的值为 infowarningerrordebug

¥Additionally, level is now a string with possible values of info, warning, error, and debug.

行为改变:WebRequestFilterurls 属性。

¥Behavior Changed: urls property of WebRequestFilter.

以前,空的 urls 数组被解释为包含所有 URL。要明确包含所有 URL,开发者现在应该使用 <all_urls> 模式,这是一个与所有可能的 URL 匹配的 指定的 URL 模式。此更改明确了意图并确保了更可预测的行为。

¥Previously, an empty urls array was interpreted as including all URLs. To explicitly include all URLs, developers should now use the <all_urls> pattern, which is a designated URL pattern that matches every possible URL. This change clarifies the intent and ensures more predictable behavior.

// Deprecated
const deprecatedFilter = {
urls: [],
};

// Replace with
const newFilter = {
urls: ['<all_urls>'],
};

已弃用:systemPreferences.isAeroGlassEnabled()

¥Deprecated: systemPreferences.isAeroGlassEnabled()

systemPreferences.isAeroGlassEnabled() 函数已被弃用,没有替换。自 Electron 23 以来,它一直返回 true,它仅支持 Windows 10+,其中 DWM 组合不再被禁用。

¥The systemPreferences.isAeroGlassEnabled() function has been deprecated without replacement. It has been always returning true since Electron 23, which only supports Windows 10+, where DWM composition can no longer be disabled.

https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw#disabling-dwm-composition-windows7-and-earlier

32.x.y 停止支持

¥End of Support for 32.x.y

Electron 32.x.y 已根据项目的 支持政策 终止支持。建议开发者和应用升级到较新版本的 Electron。

¥Electron 32.x.y has reached end-of-support as per the project's support policy. Developers and applications are encouraged to upgrade to a newer version of Electron.

E35 (2025 年 3 月)E36 (2025 年 4 月)E37 (2025 年 6 月)
35.x.y36.x.y37.x.y
34.x.y35.x.y36.x.y
33.x.y34.x.y35.x.y

下一步计划

¥What's Next

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。

¥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.

你可以找到 Electron 公开时间线

¥You can find Electron's public timeline here.

有关未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥More information about future changes can be found on the Planned Breaking Changes page.

2025 年 Google 编程夏令营

· 12 min read

Electron 再次被接受为 2025 年 Google Summer of Code (GSoC) 的指导机构!Google Summer of Code 是一项全球性计划,致力于将新的贡献者引入开源软件开发。

¥Electron has once again been accepted as a mentoring organization for Google Summer of Code (GSoC) 2025! Google Summer of Code is a global program focused on bringing new contributors into open source software development.

有关该程序的更多详细信息,请访问 Google 的 Summer of Code 主页

¥For more details about the program, visit Google’s Summer of Code homepage.

关于我们

¥About us

Electron 是一个使用 Web 技术构建跨平台桌面应用的 JavaScript 框架。Electron 的核心框架是一个使用 ChromiumNode.js 构建的编译二进制可执行文件,主要用 C++ 编写。

¥Electron is a JavaScript framework for building cross-platform desktop applications using web technologies. The core Electron framework is a compiled binary executable built with Chromium and Node.js, and is mostly written in C++.

除了 Electron 核心代码库之外,我们还维护着几个支持 Electron 生态系统的项目,包括:

¥Outside of the Electron core repository, we also maintain several projects to support the Electron ecosystem, including:

作为 GSoC 贡献者,你将有机会与 Electron 的一些核心贡献者合作,参与 github.com/electron 旗下的众多项目之一。

¥As a GSoC contributor, you will have the opportunity to collaborate with some of Electron’s core contributors on one of many projects under the github.com/electron umbrella.

应用前

¥Before applying

如果你对 Electron 不太熟悉,我们建议你先阅读 documentation 并尝试 Electron Fiddle 中的一些示例。

¥If you aren’t very familiar with Electron, we would recommend you start by reading the documentation and trying out some of the examples in Electron Fiddle.

要了解有关分发 Electron 应用的更多信息,请尝试使用 Electron Forge 创建示例应用:

¥To learn more about distributing Electron apps, try creating a sample application with Electron Forge:

npm init electron-app@latest my-app

在熟悉代码后,加入 Electron Discord 服务器 的讨论吧。

¥After familiarizing yourself with the code a bit, come join the conversation on the Electron Discord server.

信息

如果这是你第一次参加 Google Summer of Code,或者你是开源新手,我们建议你在加入社区之前先阅读 Google 的 贡献者指南

¥If this is your first time participating in Google Summer of Code or if you’re new to open source in general, we recommend reading Google’s Contributor Guide before engaging with the community.

项目贡献

¥Project contributions

我们鼓励你查看与你感兴趣的项目理念相关的任何代码库。进行研究的一种方法是通过报告错误、分类现有问题或提交拉取请求来做出贡献。这样做是使用我们的代码库进行实践的有效方法,但并非提交提案的强制性要求。一份精心编写的提案应该能够展示你对代码的理解,而无需参考过去的贡献。

¥We encourage you to take a look at any repositories that are relevant to the project ideas you are interested in. One way of doing your research is to make contributions by reporting bugs, triaging existing issues, or submitting pull requests. Doing so is an effective way of getting hands-on practice with our codebases, but is not mandatory for proposal submissions. A well-crafted proposal should be able to demonstrate your understanding of the code without needing to refer to past contributions.

如果你希望在提交提案之前为 Electron 做出贡献,以下是一些建议:

¥Here are a few tips if you are looking to contribute to Electron before submitting your proposal:

  1. 提交贡献时,请提供描述性问题或 PR 描述。无论代码本身如何,在贡献的书面部分投入精力都表明,你可以在协作环境中成为有效的沟通者。

    ¥Please provide descriptive issue or PR descriptions when submitting contributions. Regardless of the code itself, putting effort into the written part of a contribution shows us that you can be an effective communicator in a collaborative environment.

  2. 欢迎提交 PR 以解决未解决的问题。你无需评论某个问题,即可向维护人员询问是否可以分配你负责该问题。请注意,如果你需要完善解决方案的想法,我们仍然鼓励你讨论问题的潜在解决方案,但仅仅询问你是否可以参与其中的评论是多余的,并且会给问题跟踪器增加噪音。

    ¥PRs are always welcome for open issues. You do not need to comment on an issue asking a maintainer if you can be assigned to it. Note that we still encourage you to discuss potential solutions on an issue if you need to refine an idea for a solution, but comments strictly asking if you can work on something are redundant and add noise to the issue tracker.

  3. 低效的项目贡献(例如无效的问题报告、代码库 README 中无关紧要的措辞更改或前端代码的细微风格更改)将对你的最终提案产生负面影响,因为它们会占用维护人员有限的时间,并且不会给 Electron 项目带来任何净收益。

    ¥Low-effort project contributions (e.g. invalid issue reports, trivial wording changes in a repo README, or minor stylistic changes to front-end code) will negatively impact your final proposal, as they take up limited maintainer time and do not provide any net benefit to the Electron project.

  4. 虽然 AI 编程助手可以成为调试和理解新概念的有效工具,但我们强烈反对直接从 AI 生成的输出中复制/粘贴的贡献。这些通常质量较差,维护人员清理 LLM 生成的代码通常比我们直接拒绝 PR 更费力。

    ¥While AI coding assistants can be an effective tool for debugging and understanding new concepts, we highly discourage contributions that are copy/pasted directly from AI-generated output. These often turn out to be of low quality, and it's often more effort for maintainers to clean up code generated from an LLM than for us to just reject a PR altogether.

制定你的提案

¥Crafting your proposal

有兴趣与 Electron 合作吗?首先,请查看我们准备的 七个项目构想草稿。所有列出的想法均开放征求意见。

¥Interested in collaborating with Electron? First, check out the seven project idea drafts we have prepared. All listed ideas are open for proposals.

如果你有独特的想法(不在列表中),我们愿意考虑,但请确保你的提案详细且完整。如有疑问,我们建议你坚持我们列出的建议。

¥If you have a unique idea not on the list, we are open to considering it, but ensure your proposal is detailed and thoroughly outlined. When in doubt, we recommend sticking with our listed ideas.

你的应用应包含:

¥Your application should include:

  • 一份详细的提案,概述了你计划在夏季实现的目标。

    ¥A detailed proposal outlining what you plan to achieve over the summer.

  • 你的开发者背景。如果你有简历,请附上副本。或者,请告诉我们你过去的技术经验。

    ¥Your background as a developer. If you have a resume, please include a copy. Otherwise, tell us about your past technical experience.

    • 缺乏某些字段的经验并不会让你失去资格,但这将有助于我们的导师制定计划,为你提供最佳支持,并确保你的暑期项目取得成功。

      ¥Lack of experience in certain areas won’t disqualify you, but it will help our mentors work out a plan to best support you and make sure your summer project is successful.

Electron 应用中提交内容的详细指南请点击此处。请直接向 Google Summer of Code 门户提交提案。通过电子邮件发送给 Electron 团队的提案将不被视为最终提交。

¥A detailed guide of what to submit as part of your Electron application is here. Submit proposals directly to the Google Summer of Code portal. Proposals emailed to the Electron team will not be considered as final submissions.

有关你的提案的更多指导,我们建议你遵循 Google Summer of Code 官方提案撰写建议

¥For more guidance on your proposal, we recommend you follow the official Google Summer of Code proposal writing advice here.

申请开放时间为 2025 年 3 月 24 日,截止时间为 2025 年 4 月 8 日。

¥Applications open on March 24th, 2025 and close on April 8th, 2025.

过往项目提案

📚 对于 GSoC 2024,@piotrpdev 致力于在 Electron 核心文档中添加 API 历史记录。想了解 Piotr 在 Electron 工作期间的暑期工作,请阅读他在 2024 GSoC 项目存档 中的报告。

¥📚 For GSoC 2024, @piotrpdev, worked on adding API History to the Electron core documentation. To see what Piotr worked on during his summer with Electron, read his report in the 2024 GSoC program archives.

🔐 对于 GSoC 2022,@aryanshridhar 致力于在 Electron Fiddle 中启用上下文隔离。如果你想了解 Aryan 在 Electron 的暑期工作成果,你可以在 2022 GSoC 项目存档 上阅读他的报告。

¥🔐 For GSoC 2022, @aryanshridhar worked on enabling Context Isolation in Electron Fiddle. If you want to see what Aryan worked on during his summer with Electron, you can read his report in the 2022 GSoC program archives.

有问题吗?

¥Questions?

如果你有任何我们未在博文中解答的问题,或者对你的提案草案有任何疑问,请发送电子邮件至 summer-of-code@electronjs.org 或查看 GSoC 常见问题解答。请在发送电子邮件前阅读 我们的贡献者指南

¥If you have questions we didn’t address in this blog post or inquiries about your proposal draft, please send us an email at summer-of-code@electronjs.org or check the GSoC FAQ. Please read our contributor guidance before emailing.

资源

¥Resources

Electron 34.0.0

· 8 min read

Electron 34.0.0 已发布!此更新包含对 Chromium 132.0.6834.83、V8 13.2 和 Node 20.18.1 的升级。

¥Electron 34.0.0 has been released! It includes upgrades to Chromium 132.0.6834.83, V8 13.2, and Node 20.18.1.


Electron 团队很高兴地宣布 Electron 34.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息。

¥The Electron team is excited to announce the release of Electron 34.0.0! You can install it with npm via npm install electron@latest or download it from our releases website. Continue reading for details about this release.

如果你有任何反馈,请在 BlueskyMastodon 上与我们分享,或加入我们的社区 Discord!可以在 Electron 的 问题跟踪器 中报告错误和功能请求。

¥If you have any feedback, please share it with us on Bluesky or Mastodon, or join our community Discord! Bugs and feature requests can be reported in Electron's issue tracker.

显著变化

¥Notable Changes

HTTP 压缩共享字典管理 API

¥HTTP Compression Shared Dictionary Management APIs

HTTP 压缩允许 Web 服务器在数据被浏览器接收之前对其进行压缩。现代版本的 Chromium 支持 Brotli 和 Zstandard,它们是较新的压缩算法,与 gzip 等旧方案相比,它们对文本文件的性能更佳。

¥HTTP compression allows data to be compressed by a web server before being received by the browser. Modern versions of Chromium support Brotli and Zstandard, which are newer compression algorithms that perform better for text files than older schemes such as gzip.

自定义共享字典进一步提高了 Brotli 和 Zstandard 压缩的效率。请参阅 Chrome 开发者博客:共享词典 了解更多信息。

¥Custom shared dictionaries further improve the efficiency of Brotli and Zstandard compression. See the Chrome for Developers blog on shared dictionaries for more information.

@felixrieseberg#44950 中添加了以下 API,用于在会话级别管理共享字典:

¥@felixrieseberg added the following APIs in #44950 to manage shared dictionaries at the Session level:

  • session.getSharedDictionaryUsageInfo()

  • session.getSharedDictionaryInfo(options)

  • session.clearSharedDictionaryCache()

  • session.clearSharedDictionaryCacheForIsolationKey(options)

无响应的渲染器 JavaScript 调用堆栈

¥Unresponsive Renderer JavaScript Call Stacks

每当渲染器进程长时间挂起时,就会发生 Electron 的 unresponsive 事件。@samuelmaddock#44204 中添加的新 WebFrameMain.collectJavaScriptCallStack() API 允许你从关联的 WebFrameMain 对象(webContnets.mainFrame)收集 JavaScript 调用堆栈。

¥Electron's unresponsive event occurs whenever a renderer process hangs for an excessive period of time. The new WebFrameMain.collectJavaScriptCallStack() API added by @samuelmaddock in #44204 allows you to collect the JavaScript call stack from the associated WebFrameMain object (webContnets.mainFrame).

此 API 可用于在长时间运行的 JavaScript 事件导致进程挂起的情况下确定框架无响应的原因。有关详细信息,请参阅 拟议的 Web 标准崩溃报告 API

¥This API can be useful to determine why the frame is unresponsive in cases where there's long-running JavaScript events causing the process to hang. For more information, see the proposed web standard Crash Reporting API.

Main Process
const { app } = require('electron');

app.commandLine.appendSwitch(
'enable-features',
'DocumentPolicyIncludeJSCallStacksInCrashReports',
);

app.on('web-contents-created', (_, webContents) => {
webContents.on('unresponsive', async () => {
// Interrupt execution and collect call stack from unresponsive renderer
const callStack = await webContents.mainFrame.collectJavaScriptCallStack();
console.log('Renderer unresponsive\n', callStack);
});
});

[!WARNING] 此 API 需要启用 'Document-Policy': 'include-js-call-stacks-in-crash-reports' 标头。详细信息请参见 #45356

¥[!WARNING] This API requires the 'Document-Policy': 'include-js-call-stacks-in-crash-reports' header to be enabled. See #45356 for more details.

技术栈变更

¥Stack Changes

Electron 34 将 Chromium 从 130.0.6723.44 升级到 132.0.6834.83,将 Node 从 20.18.0 升级到 20.18.1,将 V8 从 13.0 升级到 13.2

¥Electron 34 upgrades Chromium from 130.0.6723.44 to 132.0.6834.83, Node from 20.18.0 to 20.18.1, and V8 from 13.0 to 13.2.

新功能

¥New Features

  • 添加了用于管理共享字典的 API,以提高使用 Brotli 或 ZStandard 的压缩效率。新的 API 包括 session.getSharedDictionaryUsageInfo()session.getSharedDictionaryInfo(options)session.clearSharedDictionaryCache()session.clearSharedDictionaryCacheForIsolationKey(options)#44950

    ¥Added APIs to manage shared dictionaries for compression efficiency using Brotli or ZStandard. The new APIs are session.getSharedDictionaryUsageInfo(), session.getSharedDictionaryInfo(options), session.clearSharedDictionaryCache(), and session.clearSharedDictionaryCacheForIsolationKey(options). #44950

  • 添加了 WebFrameMain.collectJavaScriptCallStack(),用于访问无响应渲染器的 JavaScript 调用堆栈。#44938

    ¥Added WebFrameMain.collectJavaScriptCallStack() for accessing the JavaScript call stack of unresponsive renderers. #44938

  • 添加了 WebFrameMain.detached,用于检测处于卸载状态的帧。

    ¥Added WebFrameMain.detached for frames in an unloading state.

    • 添加 WebFrameMain.isDestroyed() 以判断框架是否已被破坏。

      ¥Added WebFrameMain.isDestroyed() to determine if a frame has been destroyed.

    • 修复了 webFrameMain.fromId(processId, frameId) 在框架卸载时返回与给定参数不匹配的 WebFrameMain 实例的问题。#43473

      ¥Fixed webFrameMain.fromId(processId, frameId) returning a WebFrameMain instance which doesn't match the given parameters when the frame is unloading. #43473

  • 在实用程序进程中添加了错误事件,以支持 V8 致命错误的诊断报告。#43774

    ¥Added error event in utility process to support diagnostic reports on V8 fatal errors. #43774

  • 功能:GPU 加速共享纹理离屏渲染。#42953

    ¥Feat: GPU accelerated shared texture offscreen rendering. #42953

重大变化

¥Breaking Changes

行为改变:Windows 全屏时菜单栏将被隐藏

¥Behavior Changed: menu bar will be hidden during fullscreen on Windows

这使行为与 Linux 保持一致。先前行为:在 Windows 全屏显示时,菜单栏仍然可见。新行为:在 Windows 全屏显示时,菜单栏是隐藏的。

¥This brings the behavior to parity with Linux. Prior behavior: Menu bar is still visible during fullscreen on Windows. New behavior: Menu bar is hidden during fullscreen on Windows.

更正:这之前被列为 Electron 33 中的重大更改,但首次发布是在 Electron 34 中。

¥Correction: This was previously listed as a breaking change in Electron 33, but was first released in Electron 34.

31.x.y 停止支持

¥End of Support for 31.x.y

Electron 31.x.y 已根据项目的 支持政策 终止支持。建议开发者和应用升级到较新版本的 Electron。

¥Electron 31.x.y has reached end-of-support as per the project's support policy. Developers and applications are encouraged to upgrade to a newer version of Electron.

E34 (2025 年 1 月)E35 (2025 年 4 月)E36 (2025 年 6 月)
34.x.y35.x.y36.x.y
33.x.y34.x.y35.x.y
32.x.y33.x.y34.x.y

下一步计划

¥What's Next

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。

¥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.

你可以找到 Electron 公开时间线

¥You can find Electron's public timeline here.

有关未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥More information about future changes can be found on the Planned Breaking Changes page.

将我们的生态系统迁移到 Node 22

· 5 min read

2025 年初,Electron 的 npm 生态系统代码库(位于 @electron/@electron-forge/ 命名空间下)将迁移到 Node.js 22,作为最低支持版本。

¥In early 2025, Electron’s npm ecosystem repos (under the @electron/ and @electron-forge/ namespaces) will move to Node.js 22 as the minimum supported version.


这意味着什么?

¥What does this mean?

过去,Electron npm 生态系统中的软件包(Forge、Packager 等)会尽可能长时间地支持 Node 版本,即使某个版本已达到其生命周期结束 (EOL) 日期。这样做是为了确保我们不会分裂生态系统 - 我们理解许多项目依赖于旧版本的 Node,除非有迫切的升级理由,否则我们不想冒险搁浅这些项目。

¥In the past, packages in Electron’s npm ecosystem (Forge, Packager, etc) have supported Node versions for as long as possible, even after a version has reached its End-Of-Life (EOL) date. This is done to make sure we don’t fragment the ecosystem—we understand that many projects depend on older versions of Node, and we don’t want to risk stranding those projects unless there was a pressing reason to upgrade.

随着时间的推移,使用 Node.js 14 作为我们的最低版本变得越来越困难,原因如下:

¥Over time, using Node.js 14 as our minimum version has become increasingly difficult for a few reasons:

  • 由于缺乏官方的 Node.js 14 macOS ARM64 版本,我们需要维护持续集成 (CI) 基础设施解决方案,以提供全面的测试覆盖。

    ¥Lack of official Node.js 14 macOS ARM64 builds requires us to maintain CI infrastructure workarounds to provide full test coverage.

  • engines 对上游软件包依赖的要求已提前,这使得解决依赖冲突带来的供应链安全问题变得越来越困难。

    ¥engines requirements for upstream package dependencies have moved forward, making it increasingly difficult to resolve supply chain security issues with dependency bumps.

此外,Node.js 的新版本包含许多我们希望利用的改进,例如运行时原生的通用实用程序(例如 fs.globutil.parseArgs)以及全新的内置电池模块(例如 node:testnode:sqlite)。

¥Additionally, newer versions of Node.js have included many improvements that we would like to leverage, such as runtime-native common utilities (e.g. fs.glob and util.parseArgs) and entire new batteries-included modules (e.g. node:test, node:sqlite).

为什么现在升级?

¥Why upgrade now?

2024 年 7 月,Electron 生态系统工作组决定将所有软件包升级到最早的 Node 版本,该版本将支持同步 ESM 图的 require()。 (参见 nodejs/node#51977nodejs/node#53500)在该版本达到其 LTS 日期之后的未来时间点。

¥In July 2024, Electron’s Ecosystem Working Group decided to upgrade all packages to the earliest Node version where require()of synchronous ESM graphs will be supported (see nodejs/node#51977 and nodejs/node#53500) at a future point after that version reaches its LTS date.

我们决定将更新时间定为 2025 年 1 月/2 月。此次升级后,Node 22 将成为现有生态系统软件包中支持的最低版本。

¥We’ve decided to set that update time to January/February 2025. After this upgrade occurs, Node 22 will be the minimum supported version in existing ecosystem packages.

我需要采取什么措施?

¥What action do I need to take?

我们将尽可能地保持兼容性。但是,为了确保获得最佳支持,我们建议你将应用升级到 Node 22 或更高版本。

¥We’ll strive to maintain compatibility as much as possible. However, to ensure the best support, we encourage you to upgrade your apps to Node 22 or higher.

请注意,你项目中运行的 Node 版本与你当前 Electron 版本中嵌入的 Node 版本无关。

¥Note that the Node version running in your project is unrelated to the Node version embedded into your current version of Electron.

下一步是什么

¥What's next

如果你有任何问题或疑虑,请随时写信至 info@electronjs.org 。你还可以在我们的官方 Electron Discord 中找到社区支持。

¥Please feel free to write to us at info@electronjs.org if you have any questions or concerns. You can also find community support in our official Electron Discord.

十二月静默月 (2024 年 12 月)

· 2 min read

Electron 项目将在 2024 年 12 月暂停,然后在 2025 年 1 月恢复全速运行。

¥The Electron project will pause for the month of December 2024, then return to full speed in January 2025.

via GIPHY


12 月会有什么相同之处?

¥What will be the same in December

  1. 零日漏洞和其他主要安全相关版本将根据需要发布。安全事件应通过 SECURITY.md 报告。

    ¥Zero-day and other major security-related releases will be published as necessary. Security incidents should be reported via SECURITY.md.

  2. 行为准则 的报告和审核将继续进行。

    ¥Code of Conduct reports and moderation will continue.

12 月会有什么不同?

¥What will be different in December

  1. 2024 年的最后一个稳定分支今年的三个版本,包括 Electron 31、32 和 33,将于 12 月 1 日那周发布。12 月没有其他计划发布的版本。

    ¥2024's last stable branch releases for the year, which include Electron 31, 32, and 33, will occur the week of December 1st. There will be no additional planned releases in December.

  2. 12 月最后两周未发布 Nightly 和 Alpha 版本。

    ¥No Nightly and Alpha releases for the last two weeks of December.

  3. 除了少数例外,无需进行拉取请求审核或合并。

    ¥With few exceptions, no pull request reviews or merges.

  4. 任何代码库均未更新问题跟踪器。

    ¥No issue tracker updates on any repositories.

  5. 维护人员未提供 Discord 调试帮助。

    ¥No Discord debugging help from maintainers.

  6. 无需更新社交媒体内容。

    ¥No social media content updates.

2025 年再见!

¥See you all in 2025!

从 BrowserView 迁移到 WebContentsView

· 7 min read

BrowserViewElectron 30 起已弃用,并由 WebContentView 取代。值得庆幸的是,迁移过程相当轻松。

¥BrowserView has been deprecated since Electron 30 and is replaced by WebContentView. Thankfully, migrating is fairly painless.


Electron 正在从 BrowserView 迁移到 WebContentsView,以与 Chromium 的 UI 框架 Views API 保持一致。WebContentsView 提供了一个可复用的视图,直接与 Chromium 的渲染管道绑定,简化了未来的升级,并为开发者提供了将非 Web UI 元素集成到其 Electron 应用的可能性。通过采用 WebContentsView,应用不仅可以为即将到来的更新做好准备,还可以受益于更少的从长远来看,这将降低代码复杂性并减少潜在错误。

¥Electron is moving from BrowserView to WebContentsView to align with Chromium’s UI framework, the Views API. WebContentsView offers a reusable view directly tied to Chromium’s rendering pipeline, simplifying future upgrades and opening up the possibility for developers to integrate non-web UI elements to their Electron apps. By adopting WebContentsView, applications are not only prepared for upcoming updates but also benefit from reduced code complexity and fewer potential bugs in the long run.

熟悉 BrowserWindows 和 BrowserViews 的开发者应注意,BrowserWindowWebContentsView 分别是继承自 BaseWindowView 基类的子类。为了完全理解可用的实例变量和方法,请务必查阅这些基类的文档。

¥Developers familiar with BrowserWindows and BrowserViews should note that BrowserWindow and WebContentsView are subclasses inheriting from the BaseWindow and View base classes, respectively. To fully understand the available instance variables and methods, be sure to consult the documentation for these base classes.

迁移步骤

¥Migration steps

1. 将 Electron 升级到 30.0.0 或更高版本

¥ Upgrade Electron to 30.0.0 or higher

警告

Electron 版本可能包含影响你应用的重大更改。在继续进行其余迁移之前,建议先在你的应用上测试并安装 Electron 升级。Electron 各主要版本的重大变更列表可在 此处 以及 Electron 博客上各主要版本的发行说明中找到。

¥Electron releases may contain breaking changes that affect your application. It’s a good idea to test and land the Electron upgrade on your app first before proceeding with the rest of this migration. A list of breaking changes for each Electron major version can be found here as well as in the release notes for each major version on the Electron Blog.

2. 熟悉你的应用在何处使用 BrowserViews

¥ Familiarize yourself with where your application uses BrowserViews

其中一种方法是在你的代码库中搜索 new BrowserView(。这应该能让你了解你的应用如何使用 BrowserViews,以及需要迁移多少个调用点。

¥One way to do this is to search your codebase for new BrowserView(. This should give you a sense for how your application is using BrowserViews and how many call sites need to be migrated.

提示

在大多数情况下,你的应用实例化新 BrowserView 的每个实例都可以独立于其他实例进行迁移。

¥For the most part, each instance where your app instantiates new BrowserViews can be migrated in isolation from the others.

3. 迁移 BrowserView 的每个用法

¥ Migrate each usage of BrowserView

  1. 迁移实例化。这应该相当简单,因为 WebContentsViewBrowserView 的 的构造函数基本相同。两者都通过 webPreferences 参数接受 WebPreferences

    ¥Migrate the instantiation. This should be fairly straightforward because WebContentsView and BrowserView’s constructors have essentially the same shape. Both accept WebPreferences via the webPreferences param.

   - this.tabBar = new BrowserView({
+ this.tabBar = new WebContentsView({
信息

默认情况下,WebContentsView 实例化时背景为白色,而 BrowserView 实例化时背景为透明。要在 WebContentsView 中获得透明背景,请将其背景颜色设置为 RGBA 十六进制值,并将 Alpha(不透明度)通道设置为 00

¥By default, WebContentsView instantiates with a white background, while BrowserView instantiates with a transparent background. To get a transparent background in WebContentsView, set its background color to an RGBA hex value with an alpha (opaqueness) channel set to 00:

   + this.webContentsView.setBackgroundColor("#00000000");
  1. 迁移 BrowserView 添加到其父窗口的位置。

    ¥Migrate where the BrowserView gets added to its parent window.

   - this.browserWindow.addBrowserView(this.tabBar)
+ this.browserWindow.contentView.addChildView(this.tabBar);
  1. 迁移父窗口上的 BrowserView 实例方法调用。

    ¥Migrate BrowserView instance method calls on the parent window.

    旧方法新方法备注:
    win.setBrowserViewwin.contentView.removeChildView + win.contentView.addChildView
    win.getBrowserViewwin.contentView.children
    win.removeBrowserViewwin.contentView.removeChildView
    win.setTopBrowserViewwin.contentView.addChildView在现有视图上调用 addChildView 会将其重新排序到顶部。
    win.getBrowserViewswin.contentView.children
  2. setAutoResize 实例方法迁移到调整大小监听器。

    ¥Migrate the setAutoResize instance method to a resize listener.

   - this.browserView.setAutoResize({
- vertical: true,
- })

+ this.browserWindow.on('resize', () => {
+ if (!this.browserWindow || !this.webContentsView) {
+ return;
+ }
+ const bounds = this.browserWindow.getBounds();
+ this.webContentsView.setBounds({
+ x: 0,
+ y: 0,
+ width: bounds.width,
+ height: bounds.height,
+ });
+ });
tip

browserView.webContents and instance methods browserView.setBounds, browserView.getBounds , and browserView.setBackgroundColor do not need to be migrated and should work with a WebContentsView instance out of the box! :::所有现有用法

4. 测试并提交你的更改

¥ Test and commit your changes

遇到问题?查看 Electron 问题跟踪器上的 WebContentsView 标签,看看你遇到的问题是否已被报告。如果你在那里没有看到你的问题,请随时添加新的错误报告。包含测试用例要点将有助于我们更好地分类你的问题!

¥Running into issues? Check the WebContentsView tag on Electron's issue tracker to see if the issue you're encountering has been reported. If you don't see your issue there, feel free to add a new bug report. Including testcase gists will help us better triage your issue!

恭喜,你已迁移到 WebContentsViews!🎉

¥Congrats, you’ve migrated onto WebContentsViews! 🎉

Electron 33.0.0

· 8 min read

Electron 33.0.0 已发布!此更新包含对 Chromium 130.0.6723.44、V8 13.0 和 Node 20.18.0 的升级。

¥Electron 33.0.0 has been released! It includes upgrades to Chromium 130.0.6723.44, V8 13.0, and Node 20.18.0.


Electron 团队很高兴地宣布 Electron 33.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息。

¥The Electron team is excited to announce the release of Electron 33.0.0! You can install it with npm via npm install electron@latest or download it from our releases website. Continue reading for details about this release.

如果你有任何反馈,请在 TwitterMastodon 上与我们分享,或加入我们的社区 Discord!可以在 Electron 的 问题跟踪器 中报告错误和功能请求。

¥If you have any feedback, please share it with us on Twitter or Mastodon, or join our community Discord! Bugs and feature requests can be reported in Electron's issue tracker.

显著变化

¥Notable Changes

亮点

¥Highlights

  • 添加了处理程序 app.setClientCertRequestPasswordHandler(handler),以便在需要 PIN 码时帮助解锁加密设备。#41205

    ¥Added a handler, app.setClientCertRequestPasswordHandler(handler), to help unlock cryptographic devices when a PIN is needed. #41205

  • 扩展 navigationHistory API,新增 2 个函数,以便更好地管理历史记录。#42014

    ¥Extended navigationHistory API with 2 new functions for better history management. #42014

  • 改进了原生主题透明度检查。#42862

    ¥Improved native theme transparency checking. #42862

技术栈变更

¥Stack Changes

Electron 33 将 Chromium 从 128.0.6613.36 升级到 130.0.6723.44,将 Node 从 20.16.0 升级到 20.18.0,将 V8 从 12.8 升级到 13.0

¥Electron 33 upgrades Chromium from 128.0.6613.36 to 130.0.6723.44, Node from 20.16.0 to 20.18.0, and V8 from 12.8 to 13.0.

新功能

¥New Features

  • 添加了处理程序 app.setClientCertRequestPasswordHandler(handler),以便在需要 PIN 码时帮助解锁加密设备。#41205

    ¥Added a handler, app.setClientCertRequestPasswordHandler(handler), to help unlock cryptographic devices when a PIN is needed. #41205

  • 在实用程序进程中添加了错误事件,以支持 V8 致命错误的诊断报告。#43997

    ¥Added error event in utility process to support diagnostic reports on V8 fatal errors. #43997

  • 添加了 View.setBorderRadius(radius),用于自定义视图的边框半径,并兼容 WebContentsView#42320

    ¥Added View.setBorderRadius(radius) for customizing the border radius of views—with compatibility for WebContentsView. #42320

  • 扩展 navigationHistory API,新增 2 个函数,以便更好地管理历史记录。#42014

    ¥Extended navigationHistory API with 2 new functions for better history management. #42014

重大变化

¥Breaking Changes

删除:macOS 10.15 支持

¥Removed: macOS 10.15 support

Chromium 不再支持 macOS 10.15 (Catalina)。

¥macOS 10.15 (Catalina) is no longer supported by Chromium.

旧版本的 Electron 将继续在 Catalina 上运行,但需要 macOS 11(Big Sur)或更高版本才能运行 Electron v33.0.0 及更高版本。

¥Older versions of Electron will continue to run on Catalina, but macOS 11 (Big Sur) or later will be required to run Electron v33.0.0 and higher.

行为改变:原生模块现在需要 C++20

¥Behavior Changed: Native modules now require C++20

由于上游所做的更改,V8Node.js 现在都需要 C++20 作为最低版本。使用原生节点模块的开发者应该使用 --std=c++20 而不是 --std=c++17 构建他们的模块。使用 gcc9 或更低版本的图片可能需要更新到 gcc10 才能编译。详细信息请参见 #43555

¥Due to changes made upstream, both V8 and Node.js now require C++20 as a minimum version. Developers using native node modules should build their modules with --std=c++20 rather than --std=c++17. Images using gcc9 or lower may need to update to gcc10 in order to compile. See #43555 for more details.

行为改变:Windows 上的自定义协议 URL 处理

¥Behavior Changed: custom protocol URL handling on Windows

由于 Chromium 中进行了更改以支持 非特殊方案 URL,使用 Windows 文件路径的自定义协议 URL 将不再与已弃用的 protocol.registerFileProtocolBrowserWindow.loadURLWebContents.loadURL<webview>.loadURL 上的 baseURLForDataURL 属性正确配合使用。protocol.handle 也不适用于这些类型的 URL,但这不是变化,因为它一直以这种方式工作。

¥Due to changes made in Chromium to support Non-Special Scheme URLs, custom protocol URLs that use Windows file paths will no longer work correctly with the deprecated protocol.registerFileProtocol and the baseURLForDataURL property on BrowserWindow.loadURL, WebContents.loadURL, and <webview>.loadURL. protocol.handle will also not work with these types of URLs but this is not a change since it has always worked that way.

// No longer works
protocol.registerFileProtocol('other', () => {
callback({ filePath: '/path/to/my/file' });
});

const mainWindow = new BrowserWindow();
mainWindow.loadURL(
'data:text/html,<script src="loaded-from-dataurl.js"></script>',
{ baseURLForDataURL: 'other://C:\\myapp' },
);
mainWindow.loadURL('other://C:\\myapp\\index.html');

// Replace with
const path = require('node:path');
const nodeUrl = require('node:url');
protocol.handle(other, (req) => {
const srcPath = 'C:\\myapp\\';
const reqURL = new URL(req.url);
return net.fetch(
nodeUrl.pathToFileURL(path.join(srcPath, reqURL.pathname)).toString(),
);
});

mainWindow.loadURL(
'data:text/html,<script src="loaded-from-dataurl.js"></script>',
{ baseURLForDataURL: 'other://' },
);
mainWindow.loadURL('other://index.html');

行为改变:webContents 属性于 loginapp

¥Behavior Changed: webContents property on login on app

当使用 respondToAuthRequestsFromMainProcess 选项创建的 实用进程 请求触发事件时,来自 applogin 事件中的 webContents 属性将为 null

¥The webContents property in the login event from app will be null when the event is triggered for requests from the utility process created with respondToAuthRequestsFromMainProcess option.

已弃用:BrowserWindowConstructorOption.type 中的 textured 选项

¥Deprecated: textured option in BrowserWindowConstructorOption.type

BrowserWindowConstructorOptionstypetextured 选项已被弃用,没有替代品。此选项依赖于 macOS 上的 NSWindowStyleMaskTexturedBackground 样式掩码,该掩码已被弃用且没有其他选择。

¥The textured option of type in BrowserWindowConstructorOptions has been deprecated with no replacement. This option relied on the NSWindowStyleMaskTexturedBackground style mask on macOS, which has been deprecated with no alternative.

已弃用:systemPreferences.accessibilityDisplayShouldReduceTransparency

¥Deprecated: systemPreferences.accessibilityDisplayShouldReduceTransparency

systemPreferences.accessibilityDisplayShouldReduceTransparency 属性现已弃用,取而代之的是新的 nativeTheme.prefersReducedTransparency,它提供相同的信息并可跨平台工作。

¥The systemPreferences.accessibilityDisplayShouldReduceTransparency property is now deprecated in favor of the new nativeTheme.prefersReducedTransparency, which provides identical information and works cross-platform.

// Deprecated
const shouldReduceTransparency =
systemPreferences.accessibilityDisplayShouldReduceTransparency;

// Replace with:
const prefersReducedTransparency = nativeTheme.prefersReducedTransparency;

30.x.y

Electron 30.x.y 已根据项目的 支持政策 终止支持。建议开发者和应用升级到较新版本的 Electron。

¥Electron 30.x.y has reached end-of-support as per the project's support policy. Developers and applications are encouraged to upgrade to a newer version of Electron.

E33 (2024 年 10 月)E34 (2025 年 1 月)E35 (2025 年 4 月)
33.x.y34.x.y35.x.y
32.x.y33.x.y34.x.y
31.x.y32.x.y33.x.y

下一步计划

¥What's Next

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。

¥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.

你可以找到 Electron 公开时间线

¥You can find Electron's public timeline here.

有关未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥More information about future changes can be found on the Planned Breaking Changes page.

API 历史记录介绍 (GSoC 2024)

· 16 min read

Electron API 的历史变更现在将在文档中详细说明。

¥Historical changes to Electron APIs will now be detailed in the docs.


大家好👋,我是 Peter,2024 年 Electron Google Summer of Code (GSoC) 贡献者。

¥Hi 👋, I'm Peter, the 2024 Google Summer of Code (GSoC) contributor to Electron.

在 GSoC 项目期间,我为 Electron 文档及其函数、类等实现了 API 历史记录功能,其方式与 Node.js 文档 类似:允许在 API 文档 Markdown 文件中使用简单但功能强大的 YAML 模式,并在 Electron 文档网站上清晰地显示。

¥Over the course of the GSoC program, I implemented an API history feature for the Electron documentation and its functions, classes, etc. in a similar fashion to the Node.js documentation: by allowing the use of a simple but powerful YAML schema in the API documentation Markdown files and displaying it nicely on the Electron documentation website.

Electron 32.0.0

· 9 min read

Electron 32.0.0 已发布!它包含对 Chromium 128.0.6613.36、V8 12.8 和 Node 20.16.0 的升级。

¥Electron 32.0.0 has been released! It includes upgrades to Chromium 128.0.6613.36, V8 12.8, and Node 20.16.0.


Electron 团队非常高兴地宣布 Electron 32.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息。

¥The Electron team is excited to announce the release of Electron 32.0.0! You can install it with npm via npm install electron@latest or download it from our releases website. Continue reading for details about this release.

如果你有任何反馈,请在 TwitterMastodon 上与我们分享,或加入我们的社区 Discord!可以在 Electron 的 问题跟踪器 中报告错误和功能请求。

¥If you have any feedback, please share it with us on Twitter or Mastodon, or join our community Discord! Bugs and feature requests can be reported in Electron's issue tracker.

显著变化

¥Notable Changes

亮点

¥Highlights

  • 在我们的文档中添加了新的 API 版本历史记录,这是 @piotrpdev 作为 Google Summer of Code 的一部分创建的功能。你可以在 这篇博文 中了解更多信息。#42982

    ¥Added new API version history in our documentation, a feature created by @piotrpdev as part of Google Summer of Code. You can learn more about it in this blog post. #42982

  • 从 Web File API 中移除了非标准的 File.path 扩展。#42053

    ¥Removed nonstandard File.path extension from the Web File API. #42053

  • 尝试打开被阻止路径中的文件或目录时,Web 文件系统 API 中的故障路径与上游保持一致。#42993

    ¥Aligned failure pathway in Web File System API with upstream when attempting to open a file or directory in a blocked path. #42993

  • webcontents.navigationHistory 中添加了以下现有的导航相关 API:canGoBack, goBack, canGoForward, goForward, canGoToOffset, goToOffset, clear.之前的导航 API 现已弃用。#41752

    ¥Added the following existing navigation-related APIs to webcontents.navigationHistory: canGoBack, goBack, canGoForward, goForward, canGoToOffset, goToOffset, clear. The previous navigation APIs are now deprecated. #41752

技术栈变更

¥Stack Changes

Electron 32 将 Chromium 从 126.0.6478.36 升级到 128.0.6613.36,将 Node 从 20.14.0 升级到 20.16.0,将 V8 从 12.6 升级到 12.8

¥Electron 32 upgrades Chromium from 126.0.6478.36 to 128.0.6613.36, Node from 20.14.0 to 20.16.0, and V8 from 12.6 to 12.8.

新功能

¥New Features

  • 添加了对通过 app 模块的 'login' 事件响应从实用程序进程发起的身份验证请求的支持。#43317

    ¥Added support for responding to auth requests initiated from the utility process via the app module's 'login' event. #43317

  • CPUUsage 结构体中添加了 cumulativeCPUUsage 属性,该属性返回自进程启动以来 CPU 时间的总秒数。#41819

    ¥Added the cumulativeCPUUsage property to the CPUUsage structure, which returns the total seconds of CPU time used since process startup. #41819

  • webContents.navigationHistory 中添加了以下现有的导航相关 API:canGoBack, goBack, canGoForward, goForward, canGoToOffset, goToOffset, clear.#41752

    ¥Added the following existing navigation related APIs to webContents.navigationHistory: canGoBack, goBack, canGoForward, goForward, canGoToOffset, goToOffset, clear. #41752

  • 扩展 WebContentsView 以接受预先存在的 webContents 对象。#42086

    ¥Extended WebContentsView to accept pre-existing webContents objects. #42086

  • nativeTheme 中添加了新的属性 prefersReducedTransparency,用于指示用户是否已选择通过系统辅助功能设置降低操作系统级别的透明度。#43137

    ¥Added a new property prefersReducedTransparency to nativeTheme, which indicates whether the user has chosen to reduce OS-level transparency via system accessibility settings. #43137

  • 尝试打开被阻止路径中的文件或目录时,文件系统访问 API 中的故障路径与上游保持一致。#42993

    ¥Aligned failure pathway in File System Access API with upstream when attempting to open a file or directory in a blocked path. #42993

  • 在 Linux 上启用 Windows Control Overlay API。#42681

    ¥Enabled the Windows Control Overlay API on Linux. #42681

  • 在网络请求中启用 zstd 压缩。#43300

    ¥Enabled zstd compression in network requests. #43300

重大变化

¥Breaking Changes

删除:File.path

¥Removed: File.path

Web File 对象的非标准 path 属性是在 Electron 的早期版本中添加的,作为在渲染器中执行所有操作更常见的情况下处理原生文件的一种便捷方法。但是,它代表了与标准的偏差,并且也带来了轻微的安全风险,因此从 Electron 32.0 开始,它已被删除,转而使用 webUtils.getPathForFile 方法。

¥The nonstandard path property of the Web File object was added in an early version of Electron as a convenience method for working with native files when doing everything in the renderer was more common. However, it represents a deviation from the standard and poses a minor security risk as well, so beginning in Electron 32.0 it has been removed in favor of the webUtils.getPathForFile method.

// Before (renderer)
const file = document.querySelector('input[type=file]');
alert(`Uploaded file path was: ${file.path}`);
// After (renderer)
const file = document.querySelector('input[type=file]');
electron.showFilePath(file);

// After (preload)
const { contextBridge, webUtils } = require('electron');

contextBridge.exposeInMainWorld('electron', {
showFilePath(file) {
// It's best not to expose the full file path to the web content if
// possible.
const path = webUtils.getPathForFile(file);
alert(`Uploaded file path was: ${path}`);
},
});

已弃用:WebContents 上的 clearHistorycanGoBackgoBackcanGoForwardgoForwardgoToIndexcanGoToOffsetgoToOffset

¥Deprecated: clearHistory, canGoBack, goBack, canGoForward, goForward, goToIndex, canGoToOffset, goToOffset on WebContents

WebContents 实例上的导航相关 API 现已弃用。这些 API 已移至 WebContentsnavigationHistory 属性,以提供更结构化和直观的界面来管理导航历史记录。

¥Navigation-related APIs on WebContents instances are now deprecated. These APIs have been moved to the navigationHistory property of WebContents to provide a more structured and intuitive interface for managing navigation history.

// Deprecated
win.webContents.clearHistory();
win.webContents.canGoBack();
win.webContents.goBack();
win.webContents.canGoForward();
win.webContents.goForward();
win.webContents.goToIndex(index);
win.webContents.canGoToOffset();
win.webContents.goToOffset(index);

// Replace with
win.webContents.navigationHistory.clear();
win.webContents.navigationHistory.canGoBack();
win.webContents.navigationHistory.goBack();
win.webContents.navigationHistory.canGoForward();
win.webContents.navigationHistory.goForward();
win.webContents.navigationHistory.canGoToOffset();
win.webContents.navigationHistory.goToOffset(index);

行为已更改:userData 中的目录 databases 将被删除

¥Behavior changed: Directory databases in userData will be deleted

如果 app.getPath('userData') 返回的目录中有一个名为 databases 的目录,则在首次运行 Electron 32 时它将被删除。databases 目录由 WebSQL 使用,该目录在 Electron 31 中被删除。Chromium 现在执行删除此目录的清理。参见 问题 #45396

¥If you have a directory called databases in the directory returned by app.getPath('userData'), it will be deleted when Electron 32 is first run. The databases directory was used by WebSQL, which was removed in Electron 31. Chromium now performs a cleanup that deletes this directory. See issue #45396.

29.x.y 支持终止

¥End of Support for 29.x.y

Electron 29.x.y 已根据项目的 支持政策 终止支持。建议开发者和应用升级到较新版本的 Electron。

¥Electron 29.x.y has reached end-of-support as per the project's support policy. Developers and applications are encouraged to upgrade to a newer version of Electron.

E32 (2024 年 8 月)E33 (2024 年 10 月)E34 (2025 年 1 月)
32.x.y33.x.y34.x.y
31.x.y32.x.y33.x.y
30.x.y31.x.y32.x.y

下一步计划

¥What's Next

短期内,你可以预期团队将继续专注于跟上构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。

¥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.

你可以找到 Electron 公开时间线

¥You can find Electron's public timeline here.

有关未来变更的更多信息,请参阅 计划中的突发事件变更 页面。

¥More information about future changes can be found on the Planned Breaking Changes page.