fix: исправлены maskable иконки для Android - убран прозрачный фон (v3.8.3)
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m3s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 1m3s
This commit is contained in:
@@ -7,7 +7,7 @@ const path = require('path');
|
||||
|
||||
const publicDir = path.join(__dirname, 'public');
|
||||
|
||||
// Создаем SVG шаблон для иконки
|
||||
// Создаем SVG шаблон для обычной иконки (со скругленными углами)
|
||||
const createIconSVG = (size) => `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 100 100">
|
||||
<defs>
|
||||
@@ -21,10 +21,27 @@ const createIconSVG = (size) => `
|
||||
</svg>
|
||||
`;
|
||||
|
||||
// Создаем SVG шаблон для maskable иконки (без скругления, контент в безопасной зоне 80%)
|
||||
const createMaskableIconSVG = (size) => `
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 100 100">
|
||||
<defs>
|
||||
<linearGradient id="grad" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" style="stop-color:#4f46e5;stop-opacity:1" />
|
||||
<stop offset="100%" style="stop-color:#7c3aed;stop-opacity:1" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect width="100" height="100" fill="url(#grad)"/>
|
||||
<text x="50" y="66" font-family="Arial, sans-serif" font-size="48" font-weight="bold" fill="white" text-anchor="middle">P</text>
|
||||
</svg>
|
||||
`;
|
||||
|
||||
async function generateIcons() {
|
||||
// Создаем базовый SVG
|
||||
// Создаем базовые SVG
|
||||
const baseSVG = createIconSVG(512);
|
||||
const svgBuffer = Buffer.from(baseSVG);
|
||||
|
||||
const maskableSVG = createMaskableIconSVG(512);
|
||||
const maskableSvgBuffer = Buffer.from(maskableSVG);
|
||||
|
||||
// Генерируем иконки разных размеров
|
||||
const sizes = [
|
||||
@@ -37,25 +54,9 @@ async function generateIcons() {
|
||||
];
|
||||
|
||||
for (const icon of sizes) {
|
||||
let image = sharp(svgBuffer).resize(icon.size, icon.size);
|
||||
|
||||
if (icon.maskable) {
|
||||
// Для maskable иконки добавляем padding (контент в центральных 80%)
|
||||
const padding = icon.size * 0.1;
|
||||
image = sharp({
|
||||
create: {
|
||||
width: icon.size,
|
||||
height: icon.size,
|
||||
channels: 4,
|
||||
background: { r: 0, g: 0, b: 0, alpha: 0 }
|
||||
}
|
||||
})
|
||||
.composite([{
|
||||
input: await sharp(svgBuffer).resize(Math.round(icon.size * 0.8), Math.round(icon.size * 0.8)).toBuffer(),
|
||||
left: Math.round(padding),
|
||||
top: Math.round(padding)
|
||||
}]);
|
||||
}
|
||||
// Для maskable иконок используем специальный SVG с контентом в безопасной зоне
|
||||
const sourceBuffer = icon.maskable ? maskableSvgBuffer : svgBuffer;
|
||||
const image = sharp(sourceBuffer).resize(icon.size, icon.size);
|
||||
|
||||
const outputPath = path.join(publicDir, icon.name);
|
||||
await image.png().toFile(outputPath);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "play-life-web",
|
||||
"version": "3.8.2",
|
||||
"version": "3.8.3",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 12 KiB |
Reference in New Issue
Block a user