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');
|
const publicDir = path.join(__dirname, 'public');
|
||||||
|
|
||||||
// Создаем SVG шаблон для иконки
|
// Создаем SVG шаблон для обычной иконки (со скругленными углами)
|
||||||
const createIconSVG = (size) => `
|
const createIconSVG = (size) => `
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 100 100">
|
<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 100 100">
|
||||||
<defs>
|
<defs>
|
||||||
@@ -21,10 +21,27 @@ const createIconSVG = (size) => `
|
|||||||
</svg>
|
</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() {
|
async function generateIcons() {
|
||||||
// Создаем базовый SVG
|
// Создаем базовые SVG
|
||||||
const baseSVG = createIconSVG(512);
|
const baseSVG = createIconSVG(512);
|
||||||
const svgBuffer = Buffer.from(baseSVG);
|
const svgBuffer = Buffer.from(baseSVG);
|
||||||
|
|
||||||
|
const maskableSVG = createMaskableIconSVG(512);
|
||||||
|
const maskableSvgBuffer = Buffer.from(maskableSVG);
|
||||||
|
|
||||||
// Генерируем иконки разных размеров
|
// Генерируем иконки разных размеров
|
||||||
const sizes = [
|
const sizes = [
|
||||||
@@ -37,25 +54,9 @@ async function generateIcons() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const icon of sizes) {
|
for (const icon of sizes) {
|
||||||
let image = sharp(svgBuffer).resize(icon.size, icon.size);
|
// Для maskable иконок используем специальный SVG с контентом в безопасной зоне
|
||||||
|
const sourceBuffer = icon.maskable ? maskableSvgBuffer : svgBuffer;
|
||||||
if (icon.maskable) {
|
const image = sharp(sourceBuffer).resize(icon.size, icon.size);
|
||||||
// Для 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)
|
|
||||||
}]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const outputPath = path.join(publicDir, icon.name);
|
const outputPath = path.join(publicDir, icon.name);
|
||||||
await image.png().toFile(outputPath);
|
await image.png().toFile(outputPath);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "play-life-web",
|
"name": "play-life-web",
|
||||||
"version": "3.8.2",
|
"version": "3.8.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"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