跳至主要內容

Electron 25.0.0

·5 分鐘閱讀

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.js HTTP 堆疊的 Node 的 fetch() 不同。請參閱 #36733#36606
  • 新增了 protocol.handle,它取代並棄用了 protocol.{register,intercept}{String,Buffer,Stream,Http,File}Protocol#36674
  • 擴展了對 Electron 22 的支援,以符合 Chromium 和 Microsoft 的 Windows 7/8/8.1 棄用計畫。請參閱此部落格文章末尾的其他詳細資訊。

堆疊變更

重大變更

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

protocol.register*Protocolprotocol.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()#36733
    • net.fetch 支援對 file: URL 和使用 protocol.register*Protocol 註冊的自訂通訊協定的請求。#36606
  • 新增了 BrowserWindow.set/getWindowButtonPosition API。#37094
  • 新增了 protocol.handle,取代並棄用了 protocol.{register,intercept}{String,Buffer,Stream,Http,File}Protocol#36674
  • will-frame-navigate 事件新增至 webContents<webview> 標籤,只要框架階層內的任何框架嘗試瀏覽時,就會觸發該事件。#34418
  • 將起始器資訊新增至導覽器事件。此資訊可區分 window.open 和造成瀏覽的父框架,而不是由子系起始的導覽。#37085
  • 新增了 net.resolveHost,它使用 defaultSession 物件解析主機。#38152
  • 將新的 'did-resign-active' 事件新增至 app#38018
  • 將數個標準頁面大小選項新增至 webContents.print()#37159
  • enableLocalEcho 旗標新增至工作階段處理常式 ses.setDisplayMediaRequestHandler() 回呼,以便在 audioWebFrameMain 時,允許在本地輸出串流中回音遠端音訊輸入。#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 日為止。此十月份的支援日期與 Chromium 和 Microsoft 的延長支援日期一致。10 月 11 日,Electron 團隊將停止支援至最新的三個穩定主要版本,屆時將不再支援 Windows 7/8/8.1。

E25 (23 年 5 月)E26 (23 年 8 月)E27 (23 年 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--

下一步

短期內,您可以預期團隊將繼續專注於跟上構成 Electron 的主要組件(包括 Chromium、Node 和 V8)的開發進度。

您可以在此處找到 Electron 的公開時程表

有關未來變更的更多資訊,請參閱計劃的重大變更頁面。