"use client"; import { useEffect, useRef } from "react"; import { usePathname } from "next/navigation"; import { apiTelemetryPageView } from "@/lib/api"; /** * 公开站页面访问埋点:同 path 30s 内合并;跳过 /admin。 */ export default function VisitBeacon() { const pathname = usePathname(); const lastRef = useRef<{ path: string; at: number }>({ path: "", at: 0 }); useEffect(() => { if (!pathname || pathname === "/admin" || pathname.startsWith("/admin/")) return; const now = Date.now(); if (lastRef.current.path === pathname && now - lastRef.current.at < 30_000) return; lastRef.current = { path: pathname, at: now }; void apiTelemetryPageView(); }, [pathname]); return null; }