"use client"; import { useEffect, useState } from "react"; import { Heart } from "lucide-react"; import { cn } from "@/lib/cn"; interface FloatingVoteButtonProps { onClick: () => void; /** 显示前的滚动阈值(px) */ threshold?: number; className?: string; } export default function FloatingVoteButton({ onClick, threshold = 300, className, }: FloatingVoteButtonProps) { const [visible, setVisible] = useState(false); useEffect(() => { const handler = () => setVisible(window.scrollY > threshold); handler(); window.addEventListener("scroll", handler, { passive: true }); return () => window.removeEventListener("scroll", handler); }, [threshold]); return ( ); }