import React, { useState } from 'react'; import { createRoot } from 'react-dom/client'; import { Button, Space, Alert, Spin, Typography } from 'antd'; import axios from 'axios'; import { QueryClient, QueryClientProvider, } from '@tanstack/react-query'; const { Title } = Typography; // 创建QueryClient实例 const queryClient = new QueryClient(); interface MigrationResponse { success: boolean; error?: string; failedResult?: any; } const MigrationsApp: React.FC = () => { const [loading, setLoading] = useState(false); const [migrationResult, setMigrationResult] = useState(null); const runMigrations = async () => { try { setLoading(true); setMigrationResult(null); const response = await axios.get('/api/migrations'); setMigrationResult(response.data); } catch (error: any) { setMigrationResult({ success: false, error: error.response?.data?.error || '数据库迁移失败', failedResult: error.response?.data?.failedResult }); } finally { setLoading(false); } }; return (
数据库迁移管理 {loading && } {migrationResult && ( migrationResult.success ? ( ) : (

{migrationResult.error}

{migrationResult.failedResult && (
                      {JSON.stringify(migrationResult.failedResult, null, 2)}
                    
)} } type="error" showIcon /> ) )}
); }; // 渲染应用 const root = createRoot(document.getElementById('root') as HTMLElement); root.render( );