Skip to main content

Electron 28.0.0

· 6 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 使用 npm install electron@latest 安装,或从我们的发布网站下载。请继续阅读以了解此次发布的详细信息。

🌐 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

  • 已实现对 ECMAScript 模块(或 ESM)的支持(什么是 ECMAScript 模块?在这里了解更多)。这包括对 Electron 本身的 ESM 支持,以及诸如 UtilityProcess API 入口点等字段的支持。有关详细信息,请参阅我们的 ESM 文档
  • 除了在 Electron 本身启用 ESM 支持之外,Electron Forge 也支持使用 ESM 来打包、构建和开发 Electron 应用。你可以在 Forge v7.0.0 或更高版本中找到此支持。

技术栈变更

🌐 Stack Changes

新功能

🌐 New Features

  • 已启用 ESM 支持。 #37535
  • 已为 UtilityProcess API 添加 ESM 入口点。#40047
  • display 对象添加了几个属性,包括 detectedmaximumCursorSizenativeOrigin#40554
  • 在 Linux 上添加了对 ELECTRON_OZONE_PLATFORM_HINT 环境变量的支持。 #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 的帧率限制。

已移除:BrowserWindow.setTrafficLightPosition(position)

🌐 Removed: BrowserWindow.setTrafficLightPosition(position)

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

// 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,当没有自定义位置时,它会返回 null 而不是 { x: 0, y: 0 }

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