feat(admin): 独立后台壳、站点分析与聊天监管,公开站拆出主题切换与访问埋点
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
23
frontend/components/VisitBeacon.tsx
Normal file
23
frontend/components/VisitBeacon.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
"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;
|
||||
}
|
||||
Reference in New Issue
Block a user