跳到主要內容

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 的 issue 追蹤器中回報。

重大變更

重點

  • 在 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 棄用計畫相符。請參閱此部落格文章末尾的更多詳細資訊。

堆疊變更

重大變更

已棄用: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
  • webContents<webview> 標籤中新增了 will-frame-navigate 事件,每當框架階層中的任何框架嘗試導航時,都會觸發該事件。#34418
  • 將啟動器資訊新增至導航器事件。此資訊允許區分 window.open 與導致導航的父框架,而不是子框架啟動的導航。#37085
  • 新增了 net.resolveHost,它使用 defaultSession 物件解析主機。#38152
  • app 新增了 'did-resign-active' 事件。#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 日。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 的公開時程表

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