v0.0.4 - 首页更新
- 修复寻配号数据统计(API改为/api/seek/*) - 修复token作用域问题 - 可匹配数据=藏品数+网络数据
This commit is contained in:
parent
a2e6d328f0
commit
d8aac9bc3e
|
|
@ -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() {
|
|||
</div>
|
||||
<div>
|
||||
<div style={{ color: '#a78bfa', fontSize: '18px', fontWeight: '700' }}>{seekStats.totalMatchedCount || 0}</div>
|
||||
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '11px' }}>总共匹配</div>
|
||||
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '11px' }}>总共可匹配数据</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue