Files
iistwin/scripts/generate-icons.cjs
Ильяс Султанов 1f5ecb6da4 fix(number-fields): избегаем потери точности длинных чисел
- number-поля теперь рендерятся как text + inputMode=numeric,
  чтобы браузер не округлял значения через input type=number
- пробелы при вставке в number-поля удаляются
- бэкенд нормализует значения number-полей в строку перед сохранением
- добавлен хелпер normalizeFieldValueForStorage

Closes: искажение расчётного счёта и других длинных числовых полей
2026-07-07 21:03:40 +03:00

54 lines
2.4 KiB
JavaScript

const fs = require('fs');
const path = require('path');
const sizes = [72, 96, 128, 144, 152, 192, 384, 512];
const svgTemplate = (size) => `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 512 512">
<defs>
<linearGradient id="grad" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#3b82f6;stop-opacity:1" />
<stop offset="100%" style="stop-color:#1d4ed8;stop-opacity:1" />
</linearGradient>
</defs>
<rect width="512" height="512" rx="100" fill="url(#grad)"/>
<path d="M128 160 L256 100 L384 160 L384 280 L256 340 L128 280 Z" fill="none" stroke="white" stroke-width="24" stroke-linejoin="round"/>
<path d="M256 100 L256 340" stroke="white" stroke-width="24"/>
<path d="M128 160 L384 280" stroke="white" stroke-width="24"/>
<path d="M384 160 L128 280" stroke="white" stroke-width="24"/>
<circle cx="256" cy="400" r="40" fill="white" opacity="0.9"/>
</svg>`;
const iconsDir = path.join(__dirname, '..', 'client', 'public', 'icons');
if (!fs.existsSync(iconsDir)) {
fs.mkdirSync(iconsDir, { recursive: true });
}
sizes.forEach(size => {
const svg = svgTemplate(size);
const filePath = path.join(iconsDir, `icon-${size}x${size}.svg`);
fs.writeFileSync(filePath, svg);
console.log(`Created: icon-${size}x${size}.svg`);
});
const favicon = `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 512 512">
<defs>
<linearGradient id="grad" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#3b82f6;stop-opacity:1" />
<stop offset="100%" style="stop-color:#1d4ed8;stop-opacity:1" />
</linearGradient>
</defs>
<rect width="512" height="512" rx="100" fill="url(#grad)"/>
<path d="M128 160 L256 100 L384 160 L384 280 L256 340 L128 280 Z" fill="none" stroke="white" stroke-width="24" stroke-linejoin="round"/>
<path d="M256 100 L256 340" stroke="white" stroke-width="24"/>
<path d="M128 160 L384 280" stroke="white" stroke-width="24"/>
<path d="M384 160 L128 280" stroke="white" stroke-width="24"/>
<circle cx="256" cy="400" r="40" fill="white" opacity="0.9"/>
</svg>`;
fs.writeFileSync(path.join(__dirname, '..', 'client', 'public', 'favicon.svg'), favicon);
console.log('Created: favicon.svg');
console.log('\\nDone! Icons created as SVG files.');
console.log('Note: For PNG icons, you can use online converters or the sharp library.');