跳转到主要内容

Electron 28.0.0

·阅读时长 4 分钟

Electron 28.0.0 已发布! 此版本升级了 Chromium 120.0.6099.56、V8 12.0 和 Node.js 18.18.2


Electron 团队很高兴地宣布发布 Electron 28.0.0!您可以通过 npm install electron@latest 使用 npm 进行安装,或从我们的 发布网站 下载。请继续阅读以了解此版本详情。

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

重要变更

亮点

  • 实现了对 ECMAScript 模块或 ESM 的支持(什么是 ECMAScript 模块?在此了解更多。这包括对 Electron 本身以及 UtilityProcess API 入口点等方面的 ESM 支持。查看我们的 ESM 文档 了解更多详情。
  • 除了为 Electron 本身启用 ESM 支持外,Electron Forge 还支持使用 ESM 来打包、构建和开发 Electron 应用程序。您可以在 Forge v7.0.0 或更高版本中找到此支持。

技术栈变更

新特性

  • 启用了 ESM 支持。 #37535
  • UtilityProcess API 添加了 ESM 入口。 #40047
  • display 对象添加了几个属性,包括 detectedmaximumCursorSizenativeOrigin#40554
  • 在 Linux 上增加了对 ELECTRON_OZONE_PLATFORM_HINT 环境变量的支持。 #39792

破坏性变更

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

WebContents.backgroundThrottling 设置为 false 将禁用 BrowserWindow 中所有由它显示的 WebContents 的帧节流。

移除: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()

已移除 BrowserWindow.getTrafficLightPosition(),应改用 BrowserWindow.getWindowButtonPosition() API,当没有自定义位置时,该 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()

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

IpcRendererEventsenderIdsenderIsMainFrame 属性也已被移除。

移除:app.runningUnderRosettaTranslation

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

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

终止对 25.x.y 版本的支持

根据项目 支持策略,Electron 25.x.y 已结束支持。鼓励开发者和应用程序升级到更新版本的 Electron。

E28 (23年12月)E29 (24年2月)E30 (24年4月)
28.x.y29.x.y30.x.y
27.x.y28.x.y29.x.y
26.x.y27.x.y28.x.y

下一步计划

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

您可以在此处找到 Electron 的公开时间线

有关未来变更的更多信息,请参阅计划中的破坏性变更页面。