"use client"; import { useEffect, useState } from "react"; import { ArrowUp, MessageSquare } from "lucide-react"; import LikeButton from "./LikeButton"; import { scrollBehavior } from "@/lib/motion"; /** * 帖子详情移动端浮动操作条(lg 以下显示): * 长文读到中途也能点赞 / 跳评论框 / 回顶部,不必滚到文末。 */ export default function MobilePostBar({ postId, liked, likeCount, }: { postId: string; liked: boolean; likeCount: number; }) { const [showTop, setShowTop] = useState(false); useEffect(() => { const onScroll = () => setShowTop(window.scrollY > 400); onScroll(); window.addEventListener("scroll", onScroll, { passive: true }); return () => window.removeEventListener("scroll", onScroll); }, []); const scrollToComments = () => { document.getElementById("comment-input")?.scrollIntoView({ behavior: scrollBehavior(), block: "center", }); }; const scrollToTop = () => { window.scrollTo({ top: 0, behavior: scrollBehavior(), }); }; return (
{/* 放大点赞按钮的触控区域(样式见 globals.css .j13-bar-like) */}
{showTop && ( )}
); }