mirror of
https://github.com/Moe-Sakura/Wrangler-API.git
synced 2026-03-15 04:13:18 +08:00
* 初始化项目结构,包括配置、依赖和忽略文件。 * 引入核心搜索逻辑,支持流式响应以提供实时进度。 * 抽象化平台接口,并集成多个Galgame和补丁搜索源。 * 实现基于IP的速率限制功能,利用Cloudflare KV存储。 * 新增自动化脚本,用于生成平台索引文件。 * 统一HTTP请求客户端,增加超时和自定义User-Agent。 * 为部分平台添加了对`zypassword`参数的支持。
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const platformsDir = path.join(__dirname, '../src/platforms');
|
|
|
|
function generateIndexFile(directory) {
|
|
const dirPath = path.join(platformsDir, directory);
|
|
if (!fs.existsSync(dirPath)) return;
|
|
|
|
const files = fs.readdirSync(dirPath)
|
|
.filter(file => file.endsWith('.ts') && file !== 'index.ts');
|
|
|
|
if (files.length === 0) return;
|
|
|
|
const imports = files.map(file => {
|
|
const platformName = path.basename(file, '.ts');
|
|
return `import ${platformName} from "./${platformName}";`;
|
|
}).join('\n');
|
|
|
|
const platformNames = files.map(file => path.basename(file, '.ts'));
|
|
|
|
const content = `import type { Platform } from "../../types";
|
|
${imports}
|
|
|
|
const platforms: Platform[] = [
|
|
${platformNames.join(',\n ')},
|
|
];
|
|
|
|
export default platforms;
|
|
`;
|
|
|
|
fs.writeFileSync(path.join(dirPath, 'index.ts'), content.trim() + '\n');
|
|
console.log(`Generated index for ${directory} with ${files.length} platforms.`);
|
|
}
|
|
|
|
console.log('Generating platform indices...');
|
|
generateIndexFile('gal');
|
|
generateIndexFile('patch');
|
|
console.log('Done.'); |