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 的 問題追蹤器中回報。
值得注意的變更
重點
- 在 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 和 Microsoft 的 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.dev.org.tw' });
});
// Replace with
protocol.handle('some-protocol', () => {
return net.fetch('https://electron.dev.org.tw');
});
// 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,它接受 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,當沒有自訂位置時,它會傳回 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
- 將新的「did-resign-active」事件新增至
app
。#38018 - 將數個標準頁面尺寸選項新增至
webContents.print()
。#37159 - 將
enableLocalEcho
旗標新增至工作階段處理常式ses.setDisplayMediaRequestHandler()
回呼,以允許在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 和 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 的主要元件 (包括 Chromium、Node 和 V8) 的開發。
您可以在此處找到 Electron 的公開時程表。
有關未來變更的更多資訊,請參閱計畫重大變更頁面。