import { useEffect, useState } from "react"; import { LoaderCircle } from "lucide-react"; import { formatDuration } from "@/lib/image-utils"; import { cn } from "@/lib/utils"; const pendingMessages = ["正在创建图片", "马上就好了", "再等等", "正在整理细节"]; export function ImageGenerationPending({ className, label, compact = false }: { className?: string; label?: string; compact?: boolean }) { const [tick, setTick] = useState(0); useEffect(() => { const timer = window.setInterval(() => setTick((value) => value + 1), 1000); return () => window.clearInterval(timer); }, []); const index = Math.floor(tick / 2) % pendingMessages.length; const progress = Math.min(98, 10 + (1 - Math.exp(-tick / 28)) * 88); return (
{label || pendingMessages[index]}
{formatDuration(tick * 1000)} {Math.floor(progress)}%
); }