"use client"; import { useEffect, useState } from "react"; import { ArrowUp, MessageSquare } from "lucide-react"; import LikeButton from "./LikeButton"; /** * 帖子详情移动端浮动操作条(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: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth", block: "center", }); }; const scrollToTop = () => { window.scrollTo({ top: 0, behavior: window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth", }); }; return (
); }