fix(win): restore tray/taskbar and installer icons; release 1.0.5
Release / release (push) Successful in 5m8s
Release / release (push) Successful in 5m8s
- Generate build/icon.ico for electron-builder (exe/NSIS/Programs list). - Unpack branding PNGs from asar so nativeImage loads on Windows. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* Растеризует app-logo.svg в app-window-icon.png для nativeImage (Windows).
|
||||
* Пишет build/icon.png (macOS / fallback) и build/icon.ico — для exe/NSIS и «Программы и компоненты».
|
||||
* Запуск: node scripts/gen-window-icon.mjs
|
||||
*/
|
||||
import fs from 'node:fs';
|
||||
@@ -7,6 +8,7 @@ import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { Resvg } from '@resvg/resvg-js';
|
||||
import toIco from 'to-ico';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const root = path.join(__dirname, '..');
|
||||
@@ -29,4 +31,18 @@ const resvg512 = new Resvg(svg, {
|
||||
});
|
||||
const packOut = resvg512.render();
|
||||
fs.writeFileSync(packIconPath, packOut.asPng());
|
||||
console.log('wrote', packIconPath, packOut.width, 'x', packOut.height, '(electron-builder)');
|
||||
console.log('wrote', packIconPath, packOut.width, 'x', packOut.height, '(electron-builder mac / fallback)');
|
||||
|
||||
function renderPngForWidth(width) {
|
||||
const r = new Resvg(svg, {
|
||||
fitTo: { mode: 'width', value: width },
|
||||
});
|
||||
return Buffer.from(r.render().asPng());
|
||||
}
|
||||
|
||||
const icoSizes = [16, 24, 32, 48, 64, 128, 256];
|
||||
const icoPngs = icoSizes.map((w) => renderPngForWidth(w));
|
||||
const icoBuf = await toIco(icoPngs);
|
||||
const icoPath = path.join(buildDir, 'icon.ico');
|
||||
fs.writeFileSync(icoPath, icoBuf);
|
||||
console.log('wrote', icoPath, '(electron-builder win)');
|
||||
|
||||
Reference in New Issue
Block a user