|
|
|
|
@ -5,9 +5,10 @@ export default function Home() {
|
|
|
|
|
const [user, setUser] = useState(null)
|
|
|
|
|
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, snakes: 0 })
|
|
|
|
|
const currentPath = window.location.hash.slice(1) || '/'
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
useEffect(async () => {
|
|
|
|
|
const token = localStorage.getItem('token')
|
|
|
|
|
const userData = localStorage.getItem('user')
|
|
|
|
|
|
|
|
|
|
@ -51,6 +52,13 @@ export default function Home() {
|
|
|
|
|
setRecentCollections(list)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 获取一尘看板数据
|
|
|
|
|
const API_BASE = localStorage.getItem('API_BASE') || ''
|
|
|
|
|
try {
|
|
|
|
|
const yRes = await fetch(API_BASE + '/api/yichens/stats/today')
|
|
|
|
|
setYichensStats(await yRes.json())
|
|
|
|
|
} catch(e) {}
|
|
|
|
|
}
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
@ -71,11 +79,9 @@ export default function Home() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const statCards = [
|
|
|
|
|
{ label: '藏品数', value: stats.totalCount, color: '#3b82f6', icon: '📦' },
|
|
|
|
|
{ label: '藏品总数', value: stats.totalCount, color: '#3b82f6', icon: '📦' },
|
|
|
|
|
{ label: '总成本', value: formatMoney(stats.totalCost) + '万', color: '#22c55e', icon: '💰' },
|
|
|
|
|
{ label: '总收入', value: formatMoney(stats.totalRevenue) + '万', color: '#06b6d4', icon: '📈' },
|
|
|
|
|
{ label: '评级数', value: stats.gradedCount, color: '#8b5cf6', icon: '⭐' },
|
|
|
|
|
{ label: '预期利润', value: formatMoney(stats.expectedProfit) + '万', color: stats.expectedProfit >= 0 ? '#f59e0b' : '#ef4444', icon: '🎯' },
|
|
|
|
|
{ label: '总利润', value: formatMoney(stats.totalProfit) + '万', color: stats.totalProfit >= 0 ? '#10b981' : '#f43f5e', icon: '💵' }
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
@ -131,13 +137,43 @@ export default function Home() {
|
|
|
|
|
onMouseOut={e => { e.currentTarget.style.transform = 'translateY(0)' }}
|
|
|
|
|
onClick={() => window.location.hash = '#/stats'}
|
|
|
|
|
>
|
|
|
|
|
<div style={{ fontSize: '24px', marginBottom: '4px' }}>{card.icon}</div>
|
|
|
|
|
<div style={{ color: card.color, fontSize: '18px', fontWeight: '700', marginBottom: '4px' }}>{card.value}</div>
|
|
|
|
|
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '11px' }}>{card.label}</div>
|
|
|
|
|
<div style={{ color: card.color, fontSize: '20px', fontWeight: '700', marginBottom: '4px' }}>{card.value}</div>
|
|
|
|
|
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '12px' }}>{card.label}</div>
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 一尘看板数据 */}
|
|
|
|
|
<div style={{ marginBottom: '20px' }}>
|
|
|
|
|
<div style={{ color: 'rgba(255,255,255,0.7)', fontSize: '14px', marginBottom: '12px', paddingLeft: '4px' }}>一尘看板今日数据</div>
|
|
|
|
|
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(6, 1fr)', gap: '8px' }}>
|
|
|
|
|
<div style={{ background: 'linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%)', borderRadius: '12px', padding: '12px 8px', border: '1px solid rgba(255,255,255,0.08)', textAlign: 'center' }}>
|
|
|
|
|
<div style={{ color: '#3b82f6', fontSize: '16px', fontWeight: '700' }}>{yichensStats.total}</div>
|
|
|
|
|
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '10px' }}>帖子总数</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={{ background: 'linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%)', borderRadius: '12px', padding: '12px 8px', border: '1px solid rgba(255,255,255,0.08)', textAlign: 'center' }}>
|
|
|
|
|
<div style={{ color: '#10b981', fontSize: '16px', fontWeight: '700' }}>{yichensStats.deals}</div>
|
|
|
|
|
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '10px' }}>出售类</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={{ background: 'linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%)', borderRadius: '12px', padding: '12px 8px', border: '1px solid rgba(255,255,255,0.08)', textAlign: 'center' }}>
|
|
|
|
|
<div style={{ color: '#f59e0b', fontSize: '16px', fontWeight: '700' }}>{yichensStats.wants}</div>
|
|
|
|
|
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '10px' }}>求购类</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={{ background: 'linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%)', borderRadius: '12px', padding: '12px 8px', border: '1px solid rgba(255,255,255,0.08)', textAlign: 'center' }}>
|
|
|
|
|
<div style={{ color: '#fde047', fontSize: '16px', fontWeight: '700' }}>{yichensStats.dragons}</div>
|
|
|
|
|
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '10px' }}>龙钞</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={{ background: 'linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%)', borderRadius: '12px', padding: '12px 8px', border: '1px solid rgba(255,255,255,0.08)', textAlign: 'center' }}>
|
|
|
|
|
<div style={{ color: '#d97706', fontSize: '16px', fontWeight: '700' }}>{yichensStats.horses}</div>
|
|
|
|
|
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '10px' }}>马钞</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div style={{ background: 'linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%)', borderRadius: '12px', padding: '12px 8px', border: '1px solid rgba(255,255,255,0.08)', textAlign: 'center' }}>
|
|
|
|
|
<div style={{ color: '#fbcfe8', fontSize: '16px', fontWeight: '700' }}>{yichensStats.snakes}</div>
|
|
|
|
|
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '10px' }}>蛇钞</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 快捷操作 */}
|
|
|
|
|
<div style={{ marginBottom: '20px' }}>
|
|
|
|
|
<div style={{ color: 'rgba(255,255,255,0.7)', fontSize: '14px', marginBottom: '12px', paddingLeft: '4px' }}>快捷操作</div>
|
|
|
|
|
|