#!/bin/bash

echo "🔧 修复 Ant Design Pro 路由问题"
echo "================================"

# 1. 清理缓存
echo "1️⃣ 清理缓存..."
rm -rf src/.umi
rm -rf node_modules/.cache
rm -rf .umi
rm -rf .umi-production

# 2. 检查页面文件
echo "2️⃣ 检查页面文件..."
echo "✓ Vault/Trade: $(test -f src/pages/Vault/Trade/index.tsx && echo '存在' || echo '❌ 不存在')"
echo "✓ Vault/USDC: $(test -f src/pages/Vault/USDC/index.tsx && echo '存在' || echo '❌ 不存在')"
echo "✓ LP: $(test -f src/pages/LP/index.ts && echo '存在' || echo '❌ 不存在')"
echo "✓ Statistics/Holders: $(test -f src/pages/Statistics/Holders/index.tsx && echo '存在' || echo '❌ 不存在')"
echo "✓ Admin/Factory: $(test -f src/pages/Admin/Factory/index.tsx && echo '存在' || echo '❌ 不存在')"
echo "✓ Admin/Lending: $(test -f src/pages/Admin/Lending/index.tsx && echo '存在' || echo '❌ 不存在')"
echo "✓ Lending/User: $(test -f src/pages/Lending/User/index.tsx && echo '存在' || echo '❌ 不存在')"

# 3. 验证 export default
echo ""
echo "3️⃣ 验证 default export..."
for file in src/pages/Vault/Trade/index.tsx src/pages/Vault/USDC/index.tsx src/pages/Admin/Factory/index.tsx src/pages/Admin/Lending/index.tsx src/pages/Lending/User/index.tsx src/pages/Statistics/Holders/index.tsx; do
  if [ -f "$file" ]; then
    if grep -q "export default" "$file"; then
      echo "✓ $file"
    else
      echo "❌ $file - 缺少 export default"
    fi
  fi
done

echo ""
echo "4️⃣ 重启开发服务器..."
echo "================================"
echo ""
echo "请手动执行："
echo "  pnpm dev"
echo ""
echo "或者："
echo "  npm run dev"
echo ""
echo "然后在浏览器中刷新页面（Ctrl+Shift+R 或 Cmd+Shift+R）"

