"use client" import {useState} from "react" import {Loader2} from "lucide-react" import { AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@/components/ui/alert-dialog" import {Button} from "@/components/ui/button" import {Input} from "@/components/ui/input" import {Label} from "@/components/ui/label" import {Select, SelectContent, SelectItem, SelectTrigger, SelectValue,} from "@/components/ui/select" const CLEANUP_PRESETS = [3, 7, 30] interface CleanupDialogProps { open: boolean onOpenChange: (open: boolean) => void onConfirm: (retentionDays: number) => void loading: boolean } export function CleanupDialog({ open, onOpenChange, onConfirm, loading, }: CleanupDialogProps) { const [mode, setMode] = useState("7") const [customDays, setCustomDays] = useState("14") const [error, setError] = useState(null) const handleConfirm = () => { const retentionDays = mode === "custom" ? Number.parseInt(customDays, 10) : Number.parseInt(mode, 10) if (!Number.isFinite(retentionDays) || retentionDays < 1) { setError("保留天数必须大于 0") return } setError(null) onConfirm(retentionDays) } return ( 清理访问日志 删除早于指定保留天数的访问日志记录,操作不可恢复。
{mode === "custom" ? (
setCustomDays(e.target.value)} disabled={loading} />
) : null} {error ?

{error}

: null}
取消
) }