/** * 複製按鈕元件 */ import { Copy, Check } from "lucide-react"; import { useState } from "react"; import { Button } from "../ui/button"; import { toast } from "sonner@2.0.3"; interface CopyButtonProps { text: string; label?: string; } export function CopyButton({ text, label }: CopyButtonProps) { const [copied, setCopied] = useState(false); const handleCopy = async () => { try { await navigator.clipboard.writeText(text); setCopied(true); toast.success("已複製到剪貼簿"); setTimeout(() => setCopied(false), 2000); } catch (err) { toast.error("複製失敗"); } }; return ( ); }