Skip to main content

Electron 25.0.0

· 9 min read

Electron 25.0.0 已发布!它包含对 Chromium 114、V8 11.4 和 Node.js 18.15.0 的升级。请阅读下文了解更多详情!

¥Electron 25.0.0 has been released! It includes upgrades to Chromium 114, V8 11.4, and Node.js 18.15.0. Read below for more details!


Electron 团队非常高兴地宣布 Electron 25.0.0 正式发布!你可以通过 npm install electron@latest 使用 npm 安装它,也可以从我们的 发布网站。继续阅读以了解有关此版本的详细信息。

¥The Electron team is excited to announce the release of Electron 25.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.

如果你有任何反馈,请在 Twitter 上与我们分享,或加入我们的社区 Discord!可以在 Electron 的 问题跟踪器 中报告错误和功能请求。

¥If you have any feedback, please share it with us on Twitter, or join our community Discord! Bugs and feature requests can be reported in Electron's issue tracker.

显著变化

¥Notable Changes

亮点

¥Highlights

  • 在 Electron 的网络模块中实现了 net.fetch,使用了 Chromium 的网络堆栈。这与 Node 的 fetch() 不同,后者使用 Node.js 的 HTTP 堆栈。参见 #36733#36606

    ¥Implemented net.fetch within Electron's net module, using Chromium's networking stack. This differs from Node's fetch(), which uses Node.js' HTTP stack. See #36733 and #36606.

  • 已添加 protocol.handle,用于替换并弃用 protocol.{register,intercept}{String,Buffer,Stream,Http,File}Protocol#36674

    ¥Added protocol.handle, which replaces and deprecates protocol.{register,intercept}{String,Buffer,Stream,Http,File}Protocol. #36674

  • 扩展对 Electron 22 的支持,以配合 Chromium 和微软的 Windows 7/8/8.1 弃用计划。请参阅本博文末尾的更多详细信息。

    ¥Extended support for Electron 22, in order to match Chromium and Microsoft's Windows 7/8/8.1 deprecation plan. See additional details at the end of this blog post.

技术栈变更

¥Stack Changes

重大变化

¥Breaking Changes

已弃用:protocol.{register,intercept}{Buffer,String,Stream,File,Http}Protocol

¥Deprecated: protocol.{register,intercept}{Buffer,String,Stream,File,Http}Protocol

protocol.register*Protocolprotocol.intercept*Protocol 方法已替换为 protocol.handle

¥The protocol.register*Protocol and protocol.intercept*Protocol methods have been replaced with protocol.handle.

新方法可以注册新协议或拦截现有协议,并且响应可以是任何类型。

¥The new method can either register a new protocol or intercept an existing protocol, and responses can be of any type.

// 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.nodejs.cn' });
});

// Replace with
protocol.handle('some-protocol', () => {
return net.fetch('https://electron.nodejs.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)

¥Deprecated: BrowserWindow.setTrafficLightPosition(position)

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

¥BrowserWindow.setTrafficLightPosition(position) has been deprecated, the BrowserWindow.setWindowButtonPosition(position) API should be used instead which accepts null instead of { x: 0, y: 0 } to reset the position to system default.

// 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()

¥Deprecated: BrowserWindow.getTrafficLightPosition()

BrowserWindow.getTrafficLightPosition() 已被弃用,应使用 BrowserWindow.getWindowButtonPosition() API,当没有自定义位置时,它会返回 null 而不是 { x: 0, y: 0 }

¥BrowserWindow.getTrafficLightPosition() has been deprecated, the BrowserWindow.getWindowButtonPosition() API should be used instead which returns null instead of { x: 0, y: 0 } when there is no custom position.

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

新功能

¥New Features

  • 添加了 net.fetch()#36733

    ¥Added net.fetch(). #36733

    • net.fetch 支持对 file: URL 的请求以及在 protocol.register*Protocol 中注册的自定义协议。#36606

      ¥net.fetch supports requests to file: URLs and custom protocols registered with protocol.register*Protocol. #36606

  • 添加了 BrowserWindow.set/getWindowButtonPosition API。#37094

    ¥Added BrowserWindow.set/getWindowButtonPosition APIs. #37094

  • 已添加 protocol.handle,用于替换并弃用 protocol.{register,intercept}{String,Buffer,Stream,Http,File}Protocol#36674

    ¥Added protocol.handle, replacing and deprecating protocol.{register,intercept}{String,Buffer,Stream,Http,File}Protocol. #36674

  • 已将 will-frame-navigate 事件添加到 webContents<webview> 标签,该事件会在框架层次结构中的任何框架尝试导航时触发。#34418

    ¥Added a will-frame-navigate event to webContents and the <webview> tag, which fires whenever any frame within the frame hierarchy attempts to navigate. #34418

  • 在导航器事件中添加了启动器信息。这些信息可以区分 window.open 是来自父框架的导航,还是由子框架发起的导航。#37085

    ¥Added initiator information to navigator events. This information allows distinguishing window.open from a parent frame causing a navigation, as opposed to a child-initiated navigation. #37085

  • 添加了 net.resolveHost,用于使用 defaultSession 对象解析主机。#38152

    ¥Added net.resolveHost that resolves hosts using defaultSession object. #38152

  • app 添加了新的 'did-resign-active' 事件。#38018

    ¥Added new 'did-resign-active' event to app. #38018

  • webContents.print() 添加了几个标准页面大小选项。#37159

    ¥Added several standard page size options to webContents.print(). #37159

  • 在会话处理程序 ses.setDisplayMediaRequestHandler() 回调中添加了 enableLocalEcho 标志,以便在 audioWebFrameMain 时允许远程音频输入在本地输出流中回显。#37315

    ¥Added the enableLocalEcho flag to the session handler ses.setDisplayMediaRequestHandler() callback for allowing remote audio input to be echoed in the local output stream when audio is a WebFrameMain. #37315

  • powerMonitor 中添加了热管理信息。#38028

    ¥Added thermal management information to powerMonitor. #38028

  • 允许将绝对路径传递给 session.fromPath() API。#37604

    ¥Allows an absolute path to be passed to the session.fromPath() API. #37604

  • webContents 上暴露 audio-state-changed 事件。#37366

    ¥Exposes the audio-state-changed event on webContents. #37366

22.x.y 持续支持

¥22.x.y Continued Support

告别 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。

¥As noted in Farewell, Windows 7/8/8.1, Electron 22's (Chromium 108) planned end of life date will be extended from May 30, 2023 to October 10, 2023. The Electron team will continue to backport any security fixes that are part of this program to Electron 22 until October 10, 2023. The October support date follows the extended support dates from both Chromium and Microsoft. On October 11, the Electron team will drop support back to the latest three stable major versions, which will no longer support Windows 7/8/8.1.

E25 (2023 年 5 月)E26 (2023 年 8 月)E27 (2023 年 10 月)
25.x.y26.x.y27.x.y
24.x.y25.x.y26.x.y
23.x.y24.x.y25.x.y
22.x.y22.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.