- 将服务文件按功能分类到core、ai、analytics、security等目录 - 修复logger导入路径问题,统一使用相对路径 - 更新相关文件的导入路径引用 - 添加新的批量操作组件导出文件 - 修复dashboard页面中的类型错误 - 添加dotenv依赖到package.json
64 lines
2.5 KiB
JavaScript
64 lines
2.5 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const filesToFix = [
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\Finance\\Transactions.tsx',
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\Product\\ProductList.tsx',
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\Product\\CrossPlatformManage.tsx',
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\Orders\\OrderList.tsx',
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\Marketing\\index.tsx',
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\Settings\\SystemSettings.tsx',
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\MultiShopReport\\index.tsx',
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\ArbitrageMonitor\\index.tsx',
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\DynamicPricing\\index.tsx',
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\OrderMultiShopList\\index.tsx',
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\StrategyMarketplace\\index.tsx',
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\Leaderboard\\index.tsx',
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\UserAsset\\UserAssets.tsx',
|
|
'd:\\trae_projects\\makemd\\makemd\\dashboard\\src\\pages\\Suppliers\\SupplierDetail.tsx',
|
|
];
|
|
|
|
filesToFix.forEach(filePath => {
|
|
if (!fs.existsSync(filePath)) {
|
|
console.log(`File not found: ${filePath}`);
|
|
return;
|
|
}
|
|
|
|
let content = fs.readFileSync(filePath, 'utf8');
|
|
let modified = false;
|
|
|
|
// Pattern 1: value.toFixed( -> (value || 0).toFixed(
|
|
const patterns = [
|
|
{
|
|
// Match: variable.toFixed( but not already wrapped with || or ?.
|
|
regex: /(?<![|(])\b([a-zA-Z_][a-zA-Z0-9_]*(?:\.\w+)?)\.toFixed\(/g,
|
|
replacement: (match, varName) => {
|
|
// Skip if already has safe access
|
|
if (varName.includes('||') || varName.includes('?.') || varName.includes('?')) {
|
|
return match;
|
|
}
|
|
// Skip Math.random() and other safe calls
|
|
if (varName.includes('Math.random') || varName.includes('percent')) {
|
|
return match;
|
|
}
|
|
return `(${varName} || 0).toFixed(`;
|
|
}
|
|
}
|
|
];
|
|
|
|
patterns.forEach(pattern => {
|
|
const newContent = content.replace(pattern.regex, pattern.replacement);
|
|
if (newContent !== content) {
|
|
content = newContent;
|
|
modified = true;
|
|
}
|
|
});
|
|
|
|
if (modified) {
|
|
fs.writeFileSync(filePath, content, 'utf8');
|
|
console.log(`Fixed: ${path.basename(filePath)}`);
|
|
}
|
|
});
|
|
|
|
console.log('Done!');
|