"use client"; import { useEffect, useState } from "react"; import { ArrowUp } from "lucide-react"; import { scrollBehavior } from "@/lib/motion"; const SHOW_AFTER = 400; /** * 公开站长页回顶:滚过阈值后右下角浮现。 * 短页自然不出现;帖子移动端底栏时抬高,避免叠住操作条。 */ export default function BackToTop({ liftForMobileBar = false, }: { liftForMobileBar?: boolean; }) { const [visible, setVisible] = useState(false); useEffect(() => { const onScroll = () => setVisible(window.scrollY > SHOW_AFTER); onScroll(); window.addEventListener("scroll", onScroll, { passive: true }); return () => window.removeEventListener("scroll", onScroll); }, []); if (!visible) return null; return ( ); }