/** * 批量更新即梦 skill 的 qrCodeUrl,加入 fun_id 参数 * * 使用方法: * node _update-payment-funid.js * * 示例: * node _update-payment-funid.js abc123def456 * * 这会将所有 jimeng skill 的 qrCodeUrl 从: * https://app.fmode.cn/dev/apig-pay/?authid=T0iOotHcDX * 更新为: * https://app.fmode.cn/dev/apig-pay/?authid=T0iOotHcDX&fun_id=abc123def456 * * 同时也会更新 voc 等其他分类下的 skill(如果有相同 URL 的话) */ const fs = require('fs'); const path = require('path'); const funId = process.argv[2]; if (!funId) { console.error('用法: node _update-payment-funid.js '); console.error(' fun_id: 部署 apigRechargeOnPay 云函数后获取的 objectId'); process.exit(1); } const OLD_URL = 'https://app.fmode.cn/dev/apig-pay/?authid=T0iOotHcDX'; const NEW_URL = `https://app.fmode.cn/dev/apig-pay/?authid=T0iOotHcDX&fun_id=${funId}`; // 扫描所有分类目录 const rootDir = path.resolve(__dirname, '..'); const categories = ['jimeng', 'voc', 'social-media', 'competitor-analysis', 'review-analysis', 'synthesis', 'social-voc', 'douyin', 'video-creation']; let updated = 0; let scanned = 0; for (const category of categories) { const catDir = path.join(rootDir, category); if (!fs.existsSync(catDir)) continue; const dirs = fs.readdirSync(catDir, { withFileTypes: true }) .filter(d => d.isDirectory() && !d.name.startsWith('_')); for (const dir of dirs) { const configPath = path.join(catDir, dir.name, 'api-config.json'); if (!fs.existsSync(configPath)) continue; scanned++; let content = fs.readFileSync(configPath, 'utf-8'); if (content.includes(OLD_URL) && !content.includes('fun_id=')) { content = content.split(OLD_URL).join(NEW_URL); fs.writeFileSync(configPath, content, 'utf-8'); console.log(`[OK] ${category}/${dir.name}`); updated++; } } } console.log(`\n扫描 ${scanned} 个 skill,更新 ${updated} 个文件`); console.log(`新 URL: ${NEW_URL}`);