From d8aac9bc3eb1ed1df8e4eefe47ad95c03f089369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B2=E8=BE=B0=E7=94=9F=E4=BA=A7?= Date: Fri, 24 Apr 2026 15:39:19 +0800 Subject: [PATCH] =?UTF-8?q?v0.0.4=20-=20=E9=A6=96=E9=A1=B5=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复寻配号数据统计(API改为/api/seek/*) - 修复token作用域问题 - 可匹配数据=藏品数+网络数据 --- frontend/src/pages/Home.jsx | 48 ++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/frontend/src/pages/Home.jsx b/frontend/src/pages/Home.jsx index 5256610..cf3cb1d 100644 --- a/frontend/src/pages/Home.jsx +++ b/frontend/src/pages/Home.jsx @@ -1,7 +1,7 @@ /** * Home - 首页 - * Version: 0.0.2 - * 更新:快捷操作改为黑色背景(2026-04-20) + * Version: 0.0.4 (2026-04-24) + * 更新:修复寻配号数据统计API */ import React, { useState, useEffect } from 'react' @@ -66,27 +66,31 @@ export default function Home() { // 获取一尘看板数据 useEffect(() => { - fetch('/api/yichens/stats/dragons-today').then(res => res.json()).then(data => { - setDragonStats(data || {}) + const token = localStorage.getItem('token') + const headers = token ? { 'Authorization': 'Bearer ' + token } : {} + + // 寻配号统计数据 + fetch('/api/seek/stats').then(res => res.json()).then(data => { + Promise.all([ + fetch('/api/collections/stats', { headers }), + fetch('/api/yichens/posts?limit=1&offset=0') + ]).then(([colRes, yichenRes]) => Promise.all([colRes.json(), yichenRes.json()])).then(([colData, yichenData]) => { + const colCount = colData.totalCount || 0 + const yichenTotal = yichenData.total || yichenData.pagination?.total || 0 + setSeekStats({ + seekCount: data.total || 0, + matchedCount: data.matched || 0, + userMatchedCount: data.matched || 0, + totalMatchedCount: colCount + yichenTotal + }) + }).catch(() => { + setSeekStats({ seekCount: data.total||0, matchedCount: data.matched||0, userMatchedCount: data.matched||0, totalMatchedCount: 0 }) + }) }).catch(() => {}) - fetch('/api/yichens/stats/today').then(res => res.json()).then(data => { - setYichensStats(data || {}) - }).catch(() => {}) - - // 获取最新一尘帖子 - fetch('/api/yichens/stats/dragons-today').then(res => res.json()).then(data => { - setDragonStats(data || {}) - }).catch(() => {}) - - fetch('/api/yichens/posts?limit=20&offset=0').then(res => res.json()).then(data => { - setRecentPosts(data.posts || data || []) - }).catch(() => {}) - - // 获取寻配号统计数据 - fetch('/api/information/seek/stats').then(res => res.json()).then(data => { - setSeekStats(data || {}) - }).catch(() => {}) + fetch('/api/yichens/stats/dragons-today').then(res=>res.json()).then(d=>setDragonStats(d||{})).catch(()=>{}) + fetch('/api/yichens/stats/today').then(res=>res.json()).then(d=>setYichensStats(d||{})).catch(()=>{}) + fetch('/api/yichens/posts?limit=20&offset=0').then(res=>res.json()).then(d=>setRecentPosts(d.posts||d||[])).catch(()=>{}) }, []) // 检查是否为管理员 @@ -261,7 +265,7 @@ export default function Home() {
{seekStats.totalMatchedCount || 0}
-
总共匹配
+
总共可匹配数据