Electron 28.0.0
Electron 28.0.0 已发布!它包含对 Chromium 120.0.6099.56
、V8 12.0
和 Node.js 18.18.2
的升级。
Electron 团队很高兴宣布 Electron 28.0.0 发布!您可以通过 npm 使用 npm install electron@latest
安装,或者从我们的 发布网站下载。请继续阅读以了解此版本的详细信息。
如果您有任何反馈,请通过 Twitter 或 Mastodon 与我们分享,或加入我们的社区 Discord!Bug 和功能请求可以在 Electron 的问题追踪器中报告。
显著变化
亮点
- 实现了对 ECMAScript 模块 (ESM) 的支持(什么是 ECMAScript 模块?在此了解更多)。这包括 Electron 自身对 ESM 的支持,以及
UtilityProcess
API 入口点等领域。请参阅我们的 ESM 文档以了解更多详细信息。 - 除了在 Electron 本身启用 ESM 支持外,Electron Forge 还支持使用 ESM 来打包、构建和开发 Electron 应用程序。您可以在 Forge v7.0.0 或更高版本中找到此支持。
技术栈变化
- Chromium
120.0.6099.56
- Chrome 119 和 DevTools 119 中的新功能
- Chrome 120 和 DevTools 120 中的新功能
- Node
18.18.2
- V8
12.0
新功能
- 启用 ESM 支持。#37535
- 欲了解更多详情,请参阅 ESM 文档。
- 为
UtilityProcess
API 添加了 ESM 入口点。#40047 - 为
display
对象添加了多个属性,包括detected
、maximumCursorSize
和nativeOrigin
。#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
来替代。
IpcRendererEvent
的 senderId
和 senderIsMainFrame
属性也已被移除。
已移除: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 (2023年12月) | E29 (2024年2月) | E30 (2024年4月) |
---|---|---|
28.x.y | 29.x.y | 30.x.y |
27.x.y | 28.x.y | 29.x.y |
26.x.y | 27.x.y | 28.x.y |
下一步计划
在短期内,您可以期待团队将继续专注于跟进构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。
您可以在此处找到 Electron 的公开时间线。
有关未来变更的更多信息,请参见计划中的重大变更页面。