2 Commits

Author SHA1 Message Date
Ivan Fontosh 1840227be6 fix(win): restore tray/taskbar and installer icons; release 1.0.5
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>
2026-05-12 08:04:04 +08:00
Ivan Fontosh a15adfc3b1 ci(release): unpack win32 sharp package without npm install
Release / release (push) Successful in 5m9s
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-12 07:45:58 +08:00
5 changed files with 955 additions and 19 deletions
+11 -2
View File
@@ -67,9 +67,18 @@ jobs:
- run: npm ci
# Иначе EBADPLATFORM: пакет только для win32, текущий раннер — linux.
# Не используем `npm install`: на Linux npm падает с EBADPLATFORM для win32-пакета.
- name: sharp (@img/sharp-win32-x64) для Windows-артефакта при сборке на Linux
run: npm install --no-save --os=win32 --cpu=x64 @img/sharp-win32-x64@0.34.5
shell: bash
run: |
set -euo pipefail
tmp="$(mktemp -d)"
npm pack @img/sharp-win32-x64@0.34.5 --pack-destination "$tmp"
mkdir -p node_modules/@img/sharp-win32-x64
tar -xzf "$tmp/img-sharp-win32-x64-0.34.5.tgz" -C "$tmp"
cp -a "$tmp/package/." node_modules/@img/sharp-win32-x64/
test -f node_modules/@img/sharp-win32-x64/lib/sharp-win32-x64.node
rm -rf "$tmp"
- run: npm run build
+16 -7
View File
@@ -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 {
+906 -7
View File
File diff suppressed because it is too large Load Diff
+5 -2
View File
@@ -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,
+17 -1
View File
@@ -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)');