Files
MrleeAdmin/scripts/download-icons/download-icons.cjs
T
Mr.April d84d972e73 feat: 适配5.x后端,重构前端架构
主要变更:
1. 重构API目录结构,采用模块化设计,适配5.x后端接口规范
2. 优化布局组件,提升用户界面体验
3. 增强国际化支持,完善多语言配置
4. 新增权限控制功能,支持前端路由权限管理
5. 优化认证流程,支持JWT认证机制
6. 新增中间件和插件,提升系统扩展性
7. 优化状态管理,采用更清晰的模块化设计
8. 新增搜索框、广告等组件,丰富页面功能
9. 更改包管理工具从npm到pnpm,提升依赖管理效率
10. 完善配置系统,支持多环境配置

适配5.x后端特性:
- 采用新的API接口规范
- 支持JWT认证机制
- 适配后端权限控制体系
- 支持后端国际化接口
- 优化数据交互方式
2026-04-07 11:01:11 +08:00

91 lines
2.3 KiB
JavaScript

#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const https = require('https');
const ICON_SETS = [
'ant-design',
'simple-icons',
'mdi',
'material-symbols',
'tabler',
'ph',
'lucide'
];
const OUTPUT_DIR = path.join(__dirname, '../../public/icons');
function fetchJson(url) {
return new Promise((resolve, reject) => {
https.get(url, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
try {
resolve(JSON.parse(data));
} catch (error) {
reject(error);
}
});
}).on('error', reject);
});
}
async function downloadIconSet(prefix) {
try {
console.log(`Downloading ${prefix} icons...`);
const data = await fetchJson(`https://api.iconify.design/collection?prefix=${prefix}`);
const iconList = data.uncategorized || [];
if (data.categories) {
for (const category in data.categories) {
iconList.push(...(data.categories[category] || []));
}
}
const icons = iconList.map(v => `${prefix}:${v}`);
const outputPath = path.join(OUTPUT_DIR, `${prefix}.json`);
fs.writeFileSync(outputPath, JSON.stringify(icons, null, 2));
console.log(`✓ Downloaded ${icons.length} ${prefix} icons to ${outputPath}`);
return icons;
} catch (error) {
console.error(`✗ Failed to download ${prefix} icons:`, error.message);
return [];
}
}
async function downloadAllIcons() {
console.log('Starting icon download...\n');
if (!fs.existsSync(OUTPUT_DIR)) {
fs.mkdirSync(OUTPUT_DIR, { recursive: true });
}
const allIcons = {};
for (const prefix of ICON_SETS) {
const icons = await downloadIconSet(prefix);
if (icons.length > 0) {
allIcons[prefix] = icons;
}
}
const indexPath = path.join(OUTPUT_DIR, 'index.json');
fs.writeFileSync(indexPath, JSON.stringify(allIcons, null, 2));
console.log(`\n✓ All icons downloaded successfully!`);
console.log(`✓ Index file created at ${indexPath}`);
console.log(`\nTotal icon sets: ${Object.keys(allIcons).length}`);
console.log(`Total icons: ${Object.values(allIcons).reduce((sum, icons) => sum + icons.length, 0)}`);
}
downloadAllIcons().catch(console.error);