-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-icons.js
More file actions
38 lines (32 loc) · 1.34 KB
/
create-icons.js
File metadata and controls
38 lines (32 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// 簡單的 SVG 圖示生成腳本
import fs from 'fs';
import path from 'path';
const sizes = [16, 32, 48, 128];
const iconDir = 'public/icons';
// 確保目錄存在
if (!fs.existsSync(iconDir)) {
fs.mkdirSync(iconDir, { recursive: true });
}
// 生成 SVG 圖示
const svgTemplate = (size) => `
<svg width="${size}" height="${size}" viewBox="0 0 ${size} ${size}" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="grad" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#667eea;stop-opacity:1" />
<stop offset="100%" style="stop-color:#764ba2;stop-opacity:1" />
</linearGradient>
</defs>
<rect width="${size}" height="${size}" rx="${size * 0.2}" fill="url(#grad)"/>
<text x="50%" y="50%" font-family="Arial, sans-serif" font-size="${size * 0.6}"
fill="white" text-anchor="middle" dominant-baseline="middle">✨</text>
</svg>
`.trim();
// 為簡化起見,我們創建 SVG 文件作為圖示
sizes.forEach(size => {
const svgContent = svgTemplate(size);
fs.writeFileSync(path.join(iconDir, `icon${size}.svg`), svgContent);
// 同時創建一個簡單的 PNG 佔位文件(在實際項目中應該使用真正的 PNG)
// 這裡我們複製 SVG 作為佔位
fs.writeFileSync(path.join(iconDir, `icon${size}.png`), svgContent);
});
console.log('Icons created successfully!');