feat: 用户端访问足迹统计(IP 去重 UV/PV)
- 后端 Visit 模型(date+ip 唯一索引):POST /api/track 埋点(ClientIP upsert,pv+1),GET /api/admin/visits 每日 UV/PV 统计 - web 每会话上报一次访问(sessionStorage 防重),IP 由后端去重 - admin 访问统计页:侧边栏入口 + 今日/近N天 UV·PV 卡片 + 每日柱状趋势(自绘无依赖) + 7/30/90 天切换 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { useEffect } from 'react'
|
||||
import { Route, Routes } from 'react-router-dom'
|
||||
import { SiteLayout } from '@/components/layout/site-layout'
|
||||
import HomePage from '@/pages/home'
|
||||
@@ -7,6 +8,13 @@ import DownloadPage from '@/pages/download'
|
||||
import NotFoundPage from '@/pages/not-found'
|
||||
|
||||
export default function App() {
|
||||
// 访问埋点:每个会话上报一次(按 IP 在后端去重)
|
||||
useEffect(() => {
|
||||
if (sessionStorage.getItem('sundynix-tracked')) return
|
||||
sessionStorage.setItem('sundynix-tracked', '1')
|
||||
fetch('/api/track', { method: 'POST' }).catch(() => {})
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<Routes>
|
||||
<Route element={<SiteLayout />}>
|
||||
|
||||
Reference in New Issue
Block a user