65b0bb04f8
把 CarLog v2.8 全套源码 + 配置导入到 i 仓库作为 baseline: - server/src/ (13 个路由 + middleware + services + config) - server/migrations/ (0001~0018 共 18 个迁移 + mysql) - server/test/ (12 文件 101 测试) - client/src/ (20 个 view + components + stores + api + composables) - client/public/ + client/scripts/ - 全部配置文件 (.editorconfig, .eslintrc.json, .prettierrc.json, vitest.config.js, lighthouserc.json, .pa11yci.json, package.json, carlog-init.sql) - .husky/pre-commit (git hooks) - docs/install/ (宝塔部署文档) 不含: - node_modules/ (本地 npm install) - .env (敏感, 走 .env.example) - *.zip / *.log / *.sqlite / .DS_Store 新增文档 docs/DEV-PLAN.md: - Phase 1: 平台基座 (019 migration + 3 个 platform 路由 + 3 个 view) - Phase 2: CarLog 子系统化 (后端 routes/ → subsystems/carlog/ + 前端 views/ → views/subsystems/carlog/ + 元数据驱动菜单) - Phase 3: 验证 (测试 + E2E + DB 完整性) - 交付清单 + commit 模板 + 给 Mavis review 的材料 后续 Trae 实施, 提交后我 code review + 跑测试。
43 lines
1.6 KiB
JavaScript
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.');
|