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:
Blizzard
2026-07-17 17:05:08 +08:00
parent cc4aa647c5
commit 5adb3d621b
9 changed files with 260 additions and 2 deletions
+10 -1
View File
@@ -1,5 +1,13 @@
import { Link, NavLink, useNavigate } from 'react-router-dom'
import { FileText, LayoutDashboard, LogOut, Moon, Sun, X } from 'lucide-react'
import {
BarChart3,
FileText,
LayoutDashboard,
LogOut,
Moon,
Sun,
X,
} from 'lucide-react'
import { logout } from '@/api/auth'
import { useTheme } from '@/components/theme-provider'
import { LogoMark } from '@/components/logo'
@@ -8,6 +16,7 @@ import { cn } from '@/lib/utils'
const NAV = [
{ to: '/', label: '仪表盘', icon: LayoutDashboard, end: true },
{ to: '/posts', label: '文章', icon: FileText, end: false },
{ to: '/visits', label: '访问统计', icon: BarChart3, end: false },
]
interface Props {