"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} />
{/* 数据库信息卡片 */}
{dbInfoQuery.isLoading ? (
加载数据库信息中...
) : dbInfoQuery.isError ? (
获取数据库信息失败
) : (
<>
数据库类型
{dbInfo?.type === "postgres" ? "PostgreSQL" : "SQLite"}
>
)}
)
}