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!Bug 和功能请求可在 Electron 的问题跟踪器中报告。
重大更改
亮点
- 在 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 - 为会话处理程序
ses.setDisplayMediaRequestHandler()
回调添加了enableLocalEcho
标志,以允许在audio
是WebFrameMain
时,将远程音频输入回显到本地输出流中。#37315 - 为
powerMonitor
添加了热管理信息。#38028 - 允许将绝对路径传递给 session.fromPath() API。#37604
- 在
webContents
上暴露audio-state-changed
事件。#37366
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 和微软的延长支持日期。10 月 11 日,Electron 团队将把支持范围恢复到最新的三个稳定主要版本,届时将不再支持 Windows 7/8/8.1。
E25 (2023年5月) | E26 (2023年8月) | E27 (2023年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 主要组件(包括 Chromium、Node 和 V8)的开发同步。
您可以在此处找到 Electron 的公开时间线。
有关未来更改的更多信息,请参阅计划中的重大更改页面。