Files
jiang13-bbs/frontend/components/BackToTop.tsx
freefire 1d862a0dd3 feat: 站点媒体库与移动端底部导航,服务测试补强
- 新增媒体库:media_library/media_thumbs 服务(WebP 缩略图)、管理端 media 页面
- 移动端底部导航 MobileTabBar 替换 MobilePostBar
- 旧数据导入增强与测试、路由与登录会话/板块侧边栏测试补强
- site-doc 组件精简(移除 Breadcrumb),文档新增迁移公告说明
2026-09-27 02:36:11 +08:00

36 lines
994 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { useEffect, useState } from "react";
import { ArrowUp } from "lucide-react";
import { scrollBehavior } from "@/lib/motion";
const SHOW_AFTER = 400;
/**
* 公开站长页回顶:滚过阈值后右下角浮现。
* 短页自然不出现;移动端位置已为底部公共菜单预留避让(见 globals.css)。
*/
export default function BackToTop() {
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 (
<button
type="button"
className="j13-back-top j13-toast-in"
onClick={() => window.scrollTo({ top: 0, behavior: scrollBehavior() })}
aria-label="回到顶部"
>
<ArrowUp size={18} strokeWidth={2.25} aria-hidden />
</button>
);
}