掃二維碼與項(xiàng)目經(jīng)理溝通
我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問(wèn)/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
4 月 4 日,跨平臺(tái)桌面應(yīng)用開發(fā)工具 Electron 正式發(fā)布了 24.0.0 版本!該版本包括了對(duì) Chromium 112.0.5615.49、V8 11.2 和 Node.js 18.14.0 的升級(jí)。可以通過(guò)以下 npm 命令來(lái)安裝該版本:

npm install electron@latest
下面就來(lái)看看 Electron 24.0.0 都有哪些更新吧!
Chrome 112 更新詳情:https://developer.chrome.com/blog/new-in-chrome-112/
Chrome 111 更新詳情:https://developer.chrome.com/blog/new-in-chrome-111/
DevTools 112 更新詳情:https://developer.chrome.com/blog/new-in-devtools-112/
DevTools 111 更新詳情:https://developer.chrome.com/blog/new-in-devtools-111/
Node 18.12.1 更新詳情:https://nodejs.org/en/blog/release/v18.12.1/
V8 11.0
maxSize? 參數(shù)已更改為 size?,以反映傳入的大小將是創(chuàng)建的縮略圖的大小。以前,如果圖像小于 maxSize?,Windows 不會(huì)放大圖像,而 macOS 會(huì)始終將大小設(shè)置為 maxSize?,F(xiàn)在跨平臺(tái)的行為是相同的。
// 128x128 圖片
const imagePath = path.join('path', 'to', 'capybara.png');
// 放大較小的圖像
const upSize = { width: 256, height: 256 };
nativeImage.createThumbnailFromPath(imagePath, upSize).then((result) => {
console.log(result.getSize()); // { width: 256, height: 256 }
});
// 按比例縮小較大的圖像
const downSize = { width: 64, height: 64 };
nativeImage.createThumbnailFromPath(imagePath, downSize).then((result) => {
console.log(result.getSize()); // { width: 64, height: 64 }
});
BrowserWindow.setTrafficLightPosition(position)? 已被棄用,應(yīng)改用 BrowserWindow.setWindowButtonPosition(position)? API,它接受 null? 而不是 { x: 0, y: 0 } 以將位置重置為系統(tǒng)默認(rèn)值。
// 在 Electron 24 中棄用
win.setTrafficLightPosition({ x: 10, y: 10 });
win.setTrafficLightPosition({ x: 0, y: 0 });
// 替換為
win.setWindowButtonPosition({ x: 10, y: 10 });
win.setWindowButtonPosition(null);
BrowserWindow.getTrafficLightPosition()? 已被棄用,應(yīng)改用 BrowserWindow.getWindowButtonPosition()? API,當(dāng)沒(méi)有自定義位置時(shí),它返回 null? 而不是 { x: 0, y: 0 }。
// 在 Electron 24 中棄用
const pos = win.getTrafficLightPosition();
if (pos.x === 0 && pos.y === 0) {
// No custom position.
}
// 替換為
const ret = win.getWindowButtonPosition();
if (ret === null) {
// 沒(méi)有自定義位置
}
根據(jù)項(xiàng)目的支持政策,Electron 21.x.y 已終止支持。鼓勵(lì)開發(fā)人員和應(yīng)用程序升級(jí)到更新版本的 Electron。
|
E24 (2023.4) |
E25 (2023.5) |
E26 (2023.6) |
|
24.x.y |
25.x.y |
26.x.y |
|
23.x.y |
24.x.y |
25.x.y |
|
22.x.y |
23.x.y |
24.x.y |
參考:?https://www.electronjs.org/blog/electron-24-0

我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問(wèn)/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流