import { useEffect, useState } from 'react'; import { Check, Copy } from 'lucide-react'; import { IconButton } from './IconButton'; export function CopyButton({ value, label = '复制' }: { value: string; label?: string }) { const [copied, setCopied] = useState(false); useEffect(() => { if (!copied) return; const timer = window.setTimeout(() => setCopied(false), 1200); return () => window.clearTimeout(timer); }, [copied]); return ( void (async () => { try { if (!navigator.clipboard?.writeText) return; await navigator.clipboard.writeText(value); setCopied(true); } catch { setCopied(false); } })() } className="h-5 w-5" > {copied ? : } ); }