v1.2.44 首页优化,一尘看板数据展示
This commit is contained in:
parent
9d1b59a421
commit
d1d81673b2
|
|
@ -67,9 +67,9 @@ os.makedirs(uploads_dir, exist_ok=True)
|
||||||
app.mount("/uploads", StaticFiles(directory=uploads_dir), name="uploads")
|
app.mount("/uploads", StaticFiles(directory=uploads_dir), name="uploads")
|
||||||
|
|
||||||
# 挂载项目静态资源目录(可选,生产环境建议用 Nginx)
|
# 挂载项目静态资源目录(可选,生产环境建议用 Nginx)
|
||||||
# static_dir = Path(__file__).parent.parent.parent / "static"
|
static_dir = Path(__file__).parent.parent.parent / "static"
|
||||||
# if static_dir.exists():
|
if static_dir.exists():
|
||||||
# app.mount("/static", StaticFiles(directory=str(static_dir)), name="static")
|
app.mount("/static", StaticFiles(directory=str(static_dir)), name="static")
|
||||||
|
|
||||||
# 添加日志中间件
|
# 添加日志中间件
|
||||||
app.middleware("http")(logging_middleware)
|
app.middleware("http")(logging_middleware)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<title>甲辰收藏 v1.2.42</title>
|
<title>甲辰收藏 v1.2.43</title>
|
||||||
|
|
||||||
<!-- Favicon -->
|
<!-- Favicon -->
|
||||||
<link rel="icon" type="image/png" href="/static/icons/favicon.png" />
|
<link rel="icon" type="image/png" href="/static/icons/favicon.png" />
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,10 @@ export default function Home() {
|
||||||
const [user, setUser] = useState(null)
|
const [user, setUser] = useState(null)
|
||||||
const [stats, setStats] = useState({ totalCount: 0, totalCost: 0, totalRevenue: 0, expectedProfit: 0, totalProfit: 0, gradedCount: 0 })
|
const [stats, setStats] = useState({ totalCount: 0, totalCost: 0, totalRevenue: 0, expectedProfit: 0, totalProfit: 0, gradedCount: 0 })
|
||||||
const [recentCollections, setRecentCollections] = useState([])
|
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) || '/'
|
const currentPath = window.location.hash.slice(1) || '/'
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(async () => {
|
||||||
const token = localStorage.getItem('token')
|
const token = localStorage.getItem('token')
|
||||||
const userData = localStorage.getItem('user')
|
const userData = localStorage.getItem('user')
|
||||||
|
|
||||||
|
|
@ -51,6 +52,13 @@ export default function Home() {
|
||||||
setRecentCollections(list)
|
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 = [
|
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.totalCost) + '万', color: '#22c55e', icon: '💰' },
|
||||||
{ label: '总收入', value: formatMoney(stats.totalRevenue) + '万', color: '#06b6d4', 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: '💵' }
|
{ 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)' }}
|
onMouseOut={e => { e.currentTarget.style.transform = 'translateY(0)' }}
|
||||||
onClick={() => window.location.hash = '#/stats'}
|
onClick={() => window.location.hash = '#/stats'}
|
||||||
>
|
>
|
||||||
<div style={{ fontSize: '24px', marginBottom: '4px' }}>{card.icon}</div>
|
<div style={{ color: card.color, fontSize: '20px', fontWeight: '700', marginBottom: '4px' }}>{card.value}</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: '12px' }}>{card.label}</div>
|
||||||
<div style={{ color: 'rgba(255,255,255,0.5)', fontSize: '11px' }}>{card.label}</div>
|
|
||||||
</div>
|
</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={{ 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>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue