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:
@@ -70,18 +70,27 @@ function getPreloadPath(): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* PNG для иконки окна / дока: тот же растр, что electron-builder берёт из `build/icon.png`
|
||||
* (копия в dist после сборки), затем окно 256px, затем dev-пути. SVG не используем для
|
||||
* nativeImage на Windows — иначе пустая картинка и дефолтная иконка Electron вместо exe.
|
||||
* PNG для иконки окна / дока: копия `build/icon.png` в dist после сборки, затем окно 256px.
|
||||
* В упакованном приложении файлы под `dist/renderer/*.png` вынесены в `app.asar.unpacked`
|
||||
* — `nativeImage` на Windows с путём только внутри asar часто даёт пустую иконку.
|
||||
* SVG не используем для nativeImage на Windows — иначе пустая картинка и дефолт Electron.
|
||||
*/
|
||||
function resolveBrandingPngPaths(): string[] {
|
||||
const root = app.getAppPath();
|
||||
return [
|
||||
path.join(root, 'dist', 'renderer', 'app-pack-icon.png'),
|
||||
path.join(root, 'dist', 'renderer', 'app-window-icon.png'),
|
||||
const relPack = path.join('dist', 'renderer', 'app-pack-icon.png');
|
||||
const relWindow = path.join('dist', 'renderer', 'app-window-icon.png');
|
||||
const paths: string[] = [];
|
||||
if (app.isPackaged) {
|
||||
const unpacked = path.join(process.resourcesPath, 'app.asar.unpacked');
|
||||
paths.push(path.join(unpacked, relPack), path.join(unpacked, relWindow));
|
||||
}
|
||||
paths.push(
|
||||
path.join(root, relPack),
|
||||
path.join(root, relWindow),
|
||||
path.join(root, 'build', 'icon.png'),
|
||||
path.join(root, 'app', 'renderer', 'public', 'app-window-icon.png'),
|
||||
];
|
||||
);
|
||||
return paths;
|
||||
}
|
||||
|
||||
function resolveWindowIconPath(): string | undefined {
|
||||
|
||||
Generated
+906
-7
File diff suppressed because it is too large
Load Diff
+5
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "DndGamePlayer",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.5",
|
||||
"description": "DNDGamePlayer — редактор и проигрыватель игр",
|
||||
"main": "dist/main/index.cjs",
|
||||
"scripts": {
|
||||
@@ -60,6 +60,7 @@
|
||||
"javascript-obfuscator": "^4.2.2",
|
||||
"patch-package": "^8.0.1",
|
||||
"prettier": "^3.8.3",
|
||||
"to-ico": "^1.1.2",
|
||||
"tsx": "^4.21.0",
|
||||
"typescript": "^6.0.2",
|
||||
"typescript-eslint": "^8.58.2",
|
||||
@@ -82,6 +83,8 @@
|
||||
"asar": true,
|
||||
"asarUnpack": [
|
||||
"dist/preload/**",
|
||||
"dist/renderer/app-pack-icon.png",
|
||||
"dist/renderer/app-window-icon.png",
|
||||
"node_modules/sharp/**",
|
||||
"node_modules/@img/**",
|
||||
"node_modules/ffmpeg-static/**"
|
||||
@@ -121,7 +124,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"icon": "build/icon.png"
|
||||
"icon": "build/icon.ico"
|
||||
},
|
||||
"nsis": {
|
||||
"oneClick": false,
|
||||
|
||||
@@ -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