v1.2.52 - 首页优化:修改一尘标题+添加寻配号数据
This commit is contained in:
parent
31cbe53c67
commit
0bbaf87093
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
|||
))}
|
||||
</div>
|
||||
|
||||
{/* 寻配号数据 */}
|
||||
<div style={{ marginBottom: '20px' }}>
|
||||
<div style={{ color: 'rgba(255,255,255,0.7)', fontSize: '14px', marginBottom: '12px', paddingLeft: '4px' }}>🔍 寻配号数据</div>
|
||||
<div onClick={() => 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'
|
||||
}}>
|
||||
<div>
|
||||
<div style={{ color: '#fbbf24', fontSize: '18px', fontWeight: '700' }}>{seekStats.seekCount || 0}</div>
|
||||
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '12px' }}>寻号需求数</div>
|
||||
</div>
|
||||
<div style={{ textAlign: 'right' }}>
|
||||
<div style={{ color: '#34d399', fontSize: '18px', fontWeight: '700' }}>{seekStats.matchedCount || 0}</div>
|
||||
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '12px' }}>匹配成功数</div>
|
||||
</div>
|
||||
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '20px' }}>→</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 快捷操作 */}
|
||||
<div style={{ marginBottom: '20px' }}>
|
||||
<div style={{ color: 'rgba(255,255,255,0.7)', fontSize: '14px', marginBottom: '12px', paddingLeft: '4px' }}>快捷操作</div>
|
||||
|
|
@ -191,7 +222,7 @@ export default function Home() {
|
|||
|
||||
{/* 一尘今日数据 */}
|
||||
<div style={{ marginBottom: '20px' }}>
|
||||
<div style={{ color: 'rgba(255,255,255,0.7)', fontSize: '14px', marginBottom: '12px', paddingLeft: '4px' }}>📊 一尘今日数据</div>
|
||||
<div style={{ color: 'rgba(255,255,255,0.7)', fontSize: '14px', marginBottom: '12px', paddingLeft: '4px' }}>📊 一尘今日连体纪念钞数据</div>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: '8px' }}>
|
||||
<div style={{ background: 'linear-gradient(135deg, rgba(59,130,246,0.15) 0%, rgba(59,130,246,0.05) 100%)', borderRadius: '12px', padding: '12px 8px', border: '1px solid rgba(59,130,246,0.2)', textAlign: 'center' }}>
|
||||
<div style={{ color: '#60a5fa', fontSize: '20px', fontWeight: '700' }}>{yichensStats.total || 0}</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue