From 0bbaf87093e0956b11fd98d8ca89af79a248eb9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B2=E8=BE=B0=E7=94=9F=E4=BA=A7?= Date: Wed, 8 Apr 2026 12:37:39 +0800 Subject: [PATCH] =?UTF-8?q?v1.2.52=20-=20=E9=A6=96=E9=A1=B5=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=9A=E4=BF=AE=E6=94=B9=E4=B8=80=E5=B0=98=E6=A0=87?= =?UTF-8?q?=E9=A2=98+=E6=B7=BB=E5=8A=A0=E5=AF=BB=E9=85=8D=E5=8F=B7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/routers/information.py | 23 +++++++++++++++++++++ frontend/src/pages/Home.jsx | 33 +++++++++++++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/backend/app/routers/information.py b/backend/app/routers/information.py index a249fbb..9a70e31 100644 --- a/backend/app/routers/information.py +++ b/backend/app/routers/information.py @@ -1070,3 +1070,26 @@ def get_yichen_posts(category: str = None, search: str = None, page: int = 1, pa offset = (page - 1) * page_size items = query.order_by(desc(Information.created_at)).offset(offset).limit(page_size).all() return {"data": items, "pagination": {"page": page, "limit": page_size, "total": total}} + + +@router.get("/seek/stats") +def get_seek_stats( + current_user: User = Depends(get_current_user), + db: Session = Depends(get_db) +): + """获取寻配号统计数据""" + # 寻号需求数(seek类型总数) + seek_count = db.query(Information).filter( + Information.info_type == 'seek' + ).count() + + # 匹配成功总条数(is_matched = 'confirmed') + matched_count = db.query(Information).filter( + Information.info_type == 'seek', + Information.is_matched == 'confirmed' + ).count() + + return { + "seekCount": seek_count, + "matchedCount": matched_count + } diff --git a/frontend/src/pages/Home.jsx b/frontend/src/pages/Home.jsx index 1a044ca..33f5eac 100644 --- a/frontend/src/pages/Home.jsx +++ b/frontend/src/pages/Home.jsx @@ -6,6 +6,7 @@ export default function Home() { const [stats, setStats] = useState({ totalCount: 0, totalCost: 0, totalRevenue: 0, expectedProfit: 0, totalProfit: 0, gradedCount: 0 }) const [recentCollections, setRecentCollections] = useState([]) const [yichensStats, setYichensStats] = useState({ total: 0, deals: 0, wants: 0, dragons: 0, horses: 0, tianma: 0 }) + const [seekStats, setSeekStats] = useState({ seekCount: 0, matchedCount: 0 }) const [recentPosts, setRecentPosts] = useState([]) const currentPath = window.location.hash.slice(1) || '/' @@ -66,6 +67,11 @@ export default function Home() { fetch('/api/yichens/posts?limit=10&offset=0').then(res => res.json()).then(data => { setRecentPosts(Array.isArray(data) ? data : []) }).catch(() => {}) + + // 获取寻配号统计数据 + fetch('/api/information/seek/stats').then(res => res.json()).then(data => { + setSeekStats(data || {}) + }).catch(() => {}) }, []) // 检查是否为管理员 @@ -152,6 +158,31 @@ export default function Home() { ))} + {/* 寻配号数据 */} +
+
🔍 寻配号数据
+
window.location.hash = '#/news?type=seek'} style={{ + background: 'linear-gradient(135deg, rgba(245,158,11,0.15) 0%, rgba(245,158,11,0.05) 100%)', + borderRadius: '12px', + padding: '16px', + border: '1px solid rgba(245,158,11,0.2)', + cursor: 'pointer', + display: 'flex', + justifyContent: 'space-between', + alignItems: 'center' + }}> +
+
{seekStats.seekCount || 0}
+
寻号需求数
+
+
+
{seekStats.matchedCount || 0}
+
匹配成功数
+
+
+
+
+ {/* 快捷操作 */}
快捷操作
@@ -191,7 +222,7 @@ export default function Home() { {/* 一尘今日数据 */}
-
📊 一尘今日数据
+
📊 一尘今日连体纪念钞数据
{yichensStats.total || 0}