refactor(services): 重构服务文件结构,将服务按功能分类到不同目录
- 将服务文件按功能分类到core、ai、analytics、security等目录 - 修复logger导入路径问题,统一使用相对路径 - 更新相关文件的导入路径引用 - 添加新的批量操作组件导出文件 - 修复dashboard页面中的类型错误 - 添加dotenv依赖到package.json
This commit is contained in:
46
fix-data-sources-v2.js
Normal file
46
fix-data-sources-v2.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const servicesDir = 'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\services';
|
||||
|
||||
const files = fs.readdirSync(servicesDir).filter(f => f.endsWith('DataSource.ts'));
|
||||
|
||||
const fixFile = (filename) => {
|
||||
const filePath = path.join(servicesDir, filename);
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
console.log(`File not found: ${filePath}`);
|
||||
return;
|
||||
}
|
||||
|
||||
let content = fs.readFileSync(filePath, 'utf8');
|
||||
let modified = false;
|
||||
|
||||
if (content.includes(', { data)') || content.includes(', { { ')) {
|
||||
content = content.replace(/http\.(post|put|patch)\(([^,]+),\s*\{\s*(\w+)\s*\)\)/g, 'http.$1($2, $3)');
|
||||
content = content.replace(/http\.(post|put|patch)\(([^,]+),\s*\{\s*\{\s*(\w+)\s*\}\s*\)\)/g, 'http.$1($2, { $3 })');
|
||||
modified = true;
|
||||
}
|
||||
|
||||
content = content.replace(/return res\.json\(\);/g, 'return res.data;');
|
||||
content = content.replace(/return response\.json\(\);/g, 'return response.data;');
|
||||
|
||||
if (modified) {
|
||||
fs.writeFileSync(filePath, content, 'utf8');
|
||||
console.log(`Fixed: ${filename}`);
|
||||
} else {
|
||||
console.log(`No changes needed: ${filename}`);
|
||||
}
|
||||
};
|
||||
|
||||
console.log('Fixing data source files...\n');
|
||||
|
||||
files.forEach(file => {
|
||||
try {
|
||||
fixFile(file);
|
||||
} catch (error) {
|
||||
console.error(`Error fixing ${file}:`, error.message);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('\nAll files processed!');
|
||||
Reference in New Issue
Block a user