"use client" import {useState} from "react" import {Database, Download, Info, Loader2, Server} from "lucide-react" import packageJson from "../../../package.json" import {AdminService, apiConfig} from "@/lib/services" import {Card, CardContent, CardDescription, CardHeader, CardTitle} from "@/components/ui/card" import {Button} from "@/components/ui/button" import {Badge} from "@/components/ui/badge" import {useQuery} from "@tanstack/react-query" import {toast} from "sonner" function InfoRow({ label, value }: { label: string; value: React.ReactNode }) { return (
{label} {value || "-"}
) } interface InfoTabProps { systemConfigsLength: number authSourcesLength: number } export function InfoTab({ systemConfigsLength, authSourcesLength }: InfoTabProps) { const [exporting, setExporting] = useState(false) const dbInfoQuery = useQuery({ queryKey: ["admin", "db-info"], queryFn: () => AdminService.getDatabaseInfo(), }) const dbInfo = dbInfoQuery.data const handleExport = async () => { setExporting(true) try { const { blob, filename } = await AdminService.exportDatabase() const url = URL.createObjectURL(blob) const a = document.createElement("a") a.href = url a.download = filename document.body.appendChild(a) a.click() a.remove() URL.revokeObjectURL(url) toast.success("数据库导出成功", { description: `文件已下载:${filename}` }) } catch (err) { toast.error("数据库导出失败", { description: err instanceof Error ? err.message : "请求时发生未知错误", }) } finally { setExporting(false) } } return (
应用信息 当前前端应用的版本与构建信息
}).dependencies?.next} /> }).dependencies?.react} />
服务连接 前端 API 客户端的基础连接参数
{/* 数据库信息卡片 */}
数据库信息 当前使用的数据库类型及连接信息
{dbInfoQuery.isLoading ? (
加载数据库信息中...
) : dbInfoQuery.isError ? (

获取数据库信息失败

) : ( <>
数据库类型 {dbInfo?.type === "postgres" ? "PostgreSQL" : "SQLite"}
)}
) }