refactor(services): 重构服务文件结构,将服务按功能分类到不同目录

- 将服务文件按功能分类到core、ai、analytics、security等目录
- 修复logger导入路径问题,统一使用相对路径
- 更新相关文件的导入路径引用
- 添加新的批量操作组件导出文件
- 修复dashboard页面中的类型错误
- 添加dotenv依赖到package.json
This commit is contained in:
2026-03-25 13:46:26 +08:00
parent e59d7c6620
commit 2748456d8a
598 changed files with 74404 additions and 9576 deletions

52
fix-data-sources-v3.js Normal file
View File

@@ -0,0 +1,52 @@
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;
const patterns = [
{ regex: /http\.(post|put)\(([^,]+),\s*\{\s*(\w+)\s*\)\)/g, replacement: 'http.$1($2, $3)' },
{ regex: /http\.(post|put)\(([^,]+),\s*\{\s*\{\s*(\w+)\s*\}\s*\)\)/g, replacement: 'http.$1($2, { $3 })' },
{ regex: /http\.post\(([^,]+),\s*\{\s*method:\s*'DELETE'\s*\}\)/g, replacement: 'http.delete($1)' },
{ regex: /http\.post\(([^,]+),\s*\{\s*method:\s*'POST'\s*\}\)/g, replacement: 'http.post($1)' },
{ regex: /http\.post\(([^,]+),\s*\{\s*\{\s*([^}]+)\s*\}\s*\)\)/g, replacement: 'http.post($1, { $2 })' },
];
patterns.forEach(({ regex, replacement }) => {
if (regex.test(content)) {
content = content.replace(regex, replacement);
modified = true;
}
});
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!');