Electron 25.0.0
Electron 25.0.0 已经发布! 它包括对 Chromium 114、V8 11.4 和 Node.js 18.15.0 的升级。 请继续阅读以了解更多详情!
Electron 团队很高兴地宣布 Electron 25.0.0 版本发布!您可以通过 npm 使用 npm install electron@latest 安装它,或从我们的 发布网站 下载。请继续阅读以了解此版本的详细信息。
如果您有任何反馈,请在 Twitter 上与我们分享,或加入我们的社区 Discord!错误和功能请求可以在 Electron 的 问题跟踪器 中报告。
22.x.y 持续支持
如 告别 Windows 7/8/8.1 中所述,Electron 22 (Chromium 108) 计划的生命周期结束日期将从 2023 年 5 月 30 日延长至 2023 年 10 月 10 日。Electron 团队将继续将此计划中的任何安全修复程序回移植到 Electron 22,直至 2023 年 10 月 10 日。10 月的支持日期遵循 Chromium 和 Microsoft 的延长支持日期。10 月 11 日,Electron 团队将恢复对最新三个稳定主版本的支持,并且将不再支持 Windows 7/8/8.1。
| E25 (23年5月) | E26 (23年8月) | E27 (23年10月) |
|---|---|---|
| 25.x.y | 26.x.y | 27.x.y |
| 24.x.y | 25.x.y | 26.x.y |
| 23.x.y | 24.x.y | 25.x.y |
| 22.x.y | 22.x.y | -- |
值得注意的变化
- 在 Electron 的 net 模块中实现了
net.fetch,使用 Chromium 的网络堆栈。这与 Node 的fetch()不同,后者使用 Node.js 的 HTTP 堆栈。请参阅 #36733 和 #36606。 - 添加了
protocol.handle,它取代并弃用了protocol.{register,intercept}{String,Buffer,Stream,Http,File}Protocol。 #36674 - 扩展了对 Electron 22 的支持,以匹配 Chromium 和微软对 Windows 7/8/8.1 的废弃计划。 请参阅本篇博文末尾的更多细节。
堆栈变化
- Chromium
114 - Node.js
18.15.0 - V8
11.4
破坏性变更
弃用:protocol.{register,intercept}{Buffer,String,Stream,File,Http}Protocol
protocol.register*Protocol 和 protocol.intercept*Protocol 方法已被 protocol.handle 取代。
新方法既可以注册一个新协议,也可以拦截一个现有协议,并且响应可以是任何类型。
// Deprecated in Electron 25
protocol.registerBufferProtocol('some-protocol', () => {
callback({ mimeType: 'text/html', data: Buffer.from('<h5>Response</h5>') });
});
// Replace with
protocol.handle('some-protocol', () => {
return new Response(
Buffer.from('<h5>Response</h5>'), // Could also be a string or ReadableStream.
{ headers: { 'content-type': 'text/html' } },
);
});
// Deprecated in Electron 25
protocol.registerHttpProtocol('some-protocol', () => {
callback({ url: 'https://electron.js.cn' });
});
// Replace with
protocol.handle('some-protocol', () => {
return net.fetch('https://electron.js.cn');
});
// Deprecated in Electron 25
protocol.registerFileProtocol('some-protocol', () => {
callback({ filePath: '/path/to/my/file' });
});
// Replace with
protocol.handle('some-protocol', () => {
return net.fetch('file:///path/to/my/file');
});
弃用:BrowserWindow.setTrafficLightPosition(position)
BrowserWindow.setTrafficLightPosition(position) 已被弃用,应改用 BrowserWindow.setWindowButtonPosition(position) API,该 API 接受 null 而非 { x: 0, y: 0 } 来将位置重置为系统默认值。
// Deprecated in Electron 25
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 }。
// Deprecated in Electron 25
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.
}
新特性
- 添加了
net.fetch()。 #36733net.fetch支持对file:URL 和使用protocol.register*Protocol注册的自定义协议的请求。 #36606
- 添加了 BrowserWindow.set/getWindowButtonPosition API。 #37094
- 添加了
protocol.handle,取代并弃用了protocol.{register,intercept}{String,Buffer,Stream,Http,File}Protocol。 #36674 - 在
webContents和<webview>标签中添加了一个will-frame-navigate事件,每当框架层次结构内的任何框架尝试导航时都会触发该事件。 #34418 - 在导航器事件中添加了发起者信息。此信息允许区分由父框架引起的
window.open导航,与子级发起的导航。 #37085 - 添加了 net.resolveHost,它使用 defaultSession 对象解析主机。 #38152
- 在
app中添加了一个新的 'did-resign-active' 事件。 #38018 - 为
webContents.print()添加了几个标准页面大小选项。 #37159 - 在 session handler
ses.setDisplayMediaRequestHandler()回调中添加了enableLocalEcho标志,用于在audio是WebFrameMain时允许远程音频输入在本地输出流中回显。 #37315 - 为
powerMonitor添加了热管理信息。 #38028 - 允许将绝对路径传递给 session.fromPath() API。 #37604
- 公开了
webContents上的audio-state-changed事件。 #37366
接下来是什么
短期内,您可以预期团队将继续专注于跟进构成 Electron 的主要组件(包括 Chromium、Node 和 V8)的开发。
您可以在 此处 找到 Electron 的公共时间线。
有关未来变更的更多信息,请参见 计划中的破坏性变更 页面。

