Skip to main content

Electron 28.0.0

· 7 min read

Electron 28.0.0 已发布!它包含对 Chromium 120.0.6099.56、V8 12.0 和 Node.js 18.18.2 的升级。

¥Electron 28.0.0 has been released! It includes upgrades to Chromium 120.0.6099.56, V8 12.0, and Node.js 18.18.2.


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

¥The Electron team is excited to announce the release of Electron 28.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

  • 实现了对 ECMAScript 模块或 ESM(什么是 ECMAScript 模块?点击此处了解更多信息)的支持。这包括对 Electron 本身的 ESM 的支持,以及 UtilityProcess API 入口点等字段的支持。更多详情请参阅 查看我们的 ESM 文档

    ¥Implemented support for ECMAScript modules or ESM (What are ECMAScript modules? learn more here. This includes support for ESM in Electron proper, as well as areas such as the UtilityProcess API entrypoints. See our ESM documentation for more details.

  • 除了在 Electron 本身中启用 ESM 支持外,Electron Forge 还支持使用 ESM 打包、构建和开发 Electron 应用。你可以在 Forge v7.0.0 或更高版本中找到此支持。

    ¥In addition to enabling ESM support in Electron itself, Electron Forge also supports using ESM to package, build and develop Electron applications. You can find this support in Forge v7.0.0 or higher.

技术栈变更

¥Stack Changes

新功能

¥New Features

  • 启用 ESM 支持。#37535

    ¥Enabled ESM support. #37535

  • UtilityProcess API 添加了 ESM 入口点。#40047

    ¥Added ESM entrypoints to the UtilityProcess API. #40047

  • display 对象添加了多个属性,包括 detectedmaximumCursorSizenativeOrigin#40554

    ¥Added several properties to the display object including detected, maximumCursorSize, and nativeOrigin. #40554

  • 添加了对 Linux 上 ELECTRON_OZONE_PLATFORM_HINT 环境变量的支持。#39792

    ¥Added support for ELECTRON_OZONE_PLATFORM_HINT environment variable on Linux. #39792

重大变化

¥Breaking Changes

行为改变:WebContents.backgroundThrottling 设置为 false 会影响主机 BrowserWindow 中的所有 WebContents

¥Behavior Changed: WebContents.backgroundThrottling set to false affects all WebContents in the host BrowserWindow

WebContents.backgroundThrottling 设置为 false 将禁用 BrowserWindow 中显示的所有 WebContents 的帧限制。

¥WebContents.backgroundThrottling set to false will disable frames throttling in the BrowserWindow for all WebContents displayed by it.

删除:BrowserWindow.setTrafficLightPosition(position)

¥Removed: BrowserWindow.setTrafficLightPosition(position)

BrowserWindow.setTrafficLightPosition(position) 已被删除,应使用 BrowserWindow.setWindowButtonPosition(position) API,它接受 null 而不是 { x: 0, y: 0 } 将位置重置为系统默认值。

¥BrowserWindow.setTrafficLightPosition(position) has been removed, the BrowserWindow.setWindowButtonPosition(position) API should be used instead which accepts null instead of { x: 0, y: 0 } to reset the position to system default.

// Removed in Electron 28
win.setTrafficLightPosition({ x: 10, y: 10 });
win.setTrafficLightPosition({ x: 0, y: 0 });

// Replace with
win.setWindowButtonPosition({ x: 10, y: 10 });
win.setWindowButtonPosition(null);

删除:BrowserWindow.getTrafficLightPosition()

¥Removed: BrowserWindow.getTrafficLightPosition()

BrowserWindow.getTrafficLightPosition() 已被删除,应使用 BrowserWindow.getWindowButtonPosition() API,当没有自定义位置时,该 API 返回 null 而不是 { x: 0, y: 0 }

¥BrowserWindow.getTrafficLightPosition() has been removed, the BrowserWindow.getWindowButtonPosition() API should be used instead which returns null instead of { x: 0, y: 0 } when there is no custom position.

// Removed in Electron 28
const pos = win.getTrafficLightPosition();
if (pos.x === 0 && pos.y === 0) {
// No custom position.
}

// Replace with
const ret = win.getWindowButtonPosition();
if (ret === null) {
// No custom position.
}

删除:ipcRenderer.sendTo()

¥Removed: ipcRenderer.sendTo()

ipcRenderer.sendTo() API 已被删除。应通过在渲染器之间设置 MessageChannel 来替换它。

¥The ipcRenderer.sendTo() API has been removed. It should be replaced by setting up a MessageChannel between the renderers.

IpcRendererEventsenderIdsenderIsMainFrame 属性也已被删除。

¥The senderId and senderIsMainFrame properties of IpcRendererEvent have been removed as well.

删除:app.runningUnderRosettaTranslation

¥Removed: app.runningUnderRosettaTranslation

app.runningUnderRosettaTranslation 属性已被删除。请改用 app.runningUnderARM64Translation

¥The app.runningUnderRosettaTranslation property has been removed. Use app.runningUnderARM64Translation instead.

// Removed
console.log(app.runningUnderRosettaTranslation);
// Replace with
console.log(app.runningUnderARM64Translation);

25.x.y 支持终止

¥End of Support for 25.x.y

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

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

E28 (2023 年 12 月)E29 (2024 年 2 月)E30 (2024 年 4 月)
28.x.y29.x.y30.x.y
27.x.y28.x.y29.x.y
26.x.y27.x.y28.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.