Files
jiang13-bbs/frontend/components/VisitBeacon.tsx
freefire 7b327bc8cc feat: 站点访问统计与可配置侧边栏组件
- 新增访问统计:visitstats 服务与查询、visit_capture 中间件、爬虫/来源识别、管理端 analytics 页面
- 新增侧边栏:sidebar 服务与 handler、管理端 sidebar 配置页、前端侧边栏组件
- 新增 widget 嵌入代码生成(widgetCode)与 widgetApi
- 遥测逻辑迁移至 handler 层,删除 service/telemetry
- env 示例补充 Docker 部署可信代理 IP 说明
2026-09-24 18:53:45 +08:00

27 lines
973 B
TypeScript

"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 };
// 带 query 完整路径 + 来源页,供后台来源分析
const full = pathname + (typeof window !== "undefined" ? window.location.search : "");
const ref = typeof document !== "undefined" ? document.referrer : "";
void apiTelemetryPageView(full, ref);
}, [pathname]);
return null;
}