From e1b9f6fd7468d224ea7221f3cef59af7bab6ef0b Mon Sep 17 00:00:00 2001 From: yourname Date: Tue, 13 May 2025 03:50:11 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8dayjs=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=97=B6=E9=97=B4=20=E6=98=BE=E7=A4=BA=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E4=B8=BA"YYYY-MM-DD=20HH:mm:ss"=20=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E5=85=B6=E4=BB=96=E5=8A=9F=E8=83=BD=E5=92=8C?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E4=B8=8D=E5=8F=98=20=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=98=BE=E7=A4=BA=E6=B8=85=E6=99=B0=E6=98=93?= =?UTF-8?q?=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HISTORY.md | 3 +- client/migrations/migrations_app.tsx | 96 +++++++++++++++++++++++++--- server/routes_migrations.ts | 31 ++++++--- 3 files changed, 110 insertions(+), 20 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index e1b633e..3181900 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,2 +1,3 @@ 2025.05.13 0.1.0 -首页添加了迁移管理入口按钮, 无需登录即可访问 \ No newline at end of file +首页添加了迁移管理入口按钮, 无需登录即可访问 +打开迁移管理页面时,将迁移历史读取出来 \ No newline at end of file diff --git a/client/migrations/migrations_app.tsx b/client/migrations/migrations_app.tsx index 5afc548..8a98f46 100644 --- a/client/migrations/migrations_app.tsx +++ b/client/migrations/migrations_app.tsx @@ -1,10 +1,12 @@ import React, { useState } from 'react'; import { createRoot } from 'react-dom/client'; -import { Button, Space, Alert, Spin, Typography } from 'antd'; +import { Button, Space, Alert, Spin, Typography, Table } from 'antd'; import axios from 'axios'; +import dayjs from 'dayjs'; import { QueryClient, QueryClientProvider, + useQuery, } from '@tanstack/react-query'; const { Title } = Typography; @@ -18,10 +20,26 @@ interface MigrationResponse { failedResult?: any; } +interface MigrationHistory { + id: string; + name: string; + status: string; + timestamp: string; + batch: string; +} + const MigrationsApp: React.FC = () => { const [loading, setLoading] = useState(false); const [migrationResult, setMigrationResult] = useState(null); + const { data: historyData, isLoading: isHistoryLoading, error: historyError } = useQuery({ + queryKey: ['migrations-history'], + queryFn: async () => { + const response = await axios.get('/api/migrations/history'); + return response.data.history; + } + }); + const runMigrations = async () => { try { setLoading(true); @@ -40,13 +58,43 @@ const MigrationsApp: React.FC = () => { } }; + const columns = [ + { + title: '迁移名称', + dataIndex: 'name', + key: 'name', + sorter: (a: MigrationHistory, b: MigrationHistory) => a.name.localeCompare(b.name), + }, + { + title: '批次', + dataIndex: 'batch', + key: 'batch', + }, + { + title: '状态', + dataIndex: 'status', + key: 'status', + render: (status: string) => ( + + {status === 'completed' ? '已完成' : '失败'} + + ) + }, + { + title: '时间', + dataIndex: 'timestamp', + key: 'timestamp', + render: (timestamp: string) => dayjs(timestamp).format('YYYY-MM-DD HH:mm:ss') + }, + ]; + return (
数据库迁移管理 -