Files
CarLog/client/scripts/gen-pwa-icons.mjs
T
wsh5485 fe17886ac4 feat: 洗车管理系统 v2.8 — 个人 detailer 单用户全栈应用
- 车辆 / 洗车 / 加油 / 充电 / 保养 / 保险 完整 CRUD + 软删
- AI 截图识别(5 类型 OCR schema):OpenAI 兼容 + MiniMax M3
- 化学品 / Grocy 实例对接 + 库存镜像同步
- 仪表盘:30 天频次 + 健康度 + 同比环比 + 油价趋势 + 年均养护
- 月度报表:Excel 6 sheet + PDF
- PWA:manifest / SW / 离线缓存 / iOS 引导
- 安全:bcrypt + CSRF + 登录锁定(IP/用户/全局三级)+ 401 自动跳登录 + 表单草稿
- 高 ROI 8 功能:里程/提醒/成本/搜索/标签/通知/同比/成就
- 3 个新 migration(0016/0017/0018)+ 18 个迁移全幂等
- 101/101 测试通过(含 ipRateLimit / CSRF / retry / stats / tags / notifications)
- 部署:宝塔面板文档 + PM2 + Nginx
2026-06-20 21:11:54 +08:00

43 lines
1.6 KiB
JavaScript

// 用 sharp 把 SVG 转为多尺寸 PNG
import sharp from 'sharp';
import { readFile, writeFile } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const svg = await readFile(path.join(__dirname, '../public/pwa-icon.svg'));
const targets = [
// 标准 PWA icons
{ out: 'public/pwa/pwa-192x192.png', size: 192, type: 'normal' },
{ out: 'public/pwa/pwa-512x512.png', size: 512, type: 'normal' },
// maskable:四周留 20% 安全区,logo 居中缩到 60%
{ out: 'public/pwa/pwa-maskable-512x512.png', size: 512, type: 'maskable' },
// apple touch
{ out: 'public/pwa/apple-touch-icon.png', size: 180, type: 'normal' },
// favicon
{ out: 'public/favicon-32x32.png', size: 32, type: 'normal' },
{ out: 'public/favicon-16x16.png', size: 16, type: 'normal' },
];
const bgColor = { r: 27, g: 110, b: 243 }; // 渐变起始色 #1B6EF3
for (const { out, size, type } of targets) {
let buffer = await sharp(svg).resize(size, size).png().toBuffer();
if (type === 'maskable') {
// maskable 重新画:蓝底全填 + logo 60%
const inner = await sharp(svg).resize(Math.floor(size * 0.6), Math.floor(size * 0.6)).png().toBuffer();
buffer = await sharp({
create: { width: size, height: size, channels: 4, background: bgColor },
})
.composite([{ input: inner, gravity: 'center' }])
.png()
.toBuffer();
}
await writeFile(path.join(__dirname, '..', out), buffer);
console.log('✓', out, `${size}x${size}`, type);
}
console.log('Done.');