From d1d81673b22b12ac68afb4124bcfe519921db229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E5=A4=A7?= Date: Tue, 7 Apr 2026 00:44:29 +0800 Subject: [PATCH] =?UTF-8?q?v1.2.44=20=E9=A6=96=E9=A1=B5=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=8C=E4=B8=80=E5=B0=98=E7=9C=8B=E6=9D=BF=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/main.py | 6 ++--- frontend/index.html | 2 +- frontend/src/pages/Home.jsx | 50 +++++++++++++++++++++++++++++++------ 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/backend/app/main.py b/backend/app/main.py index e43e400..44d3c9a 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -67,9 +67,9 @@ os.makedirs(uploads_dir, exist_ok=True) app.mount("/uploads", StaticFiles(directory=uploads_dir), name="uploads") # 挂载项目静态资源目录(可选,生产环境建议用 Nginx) -# static_dir = Path(__file__).parent.parent.parent / "static" -# if static_dir.exists(): -# app.mount("/static", StaticFiles(directory=str(static_dir)), name="static") +static_dir = Path(__file__).parent.parent.parent / "static" +if static_dir.exists(): + app.mount("/static", StaticFiles(directory=str(static_dir)), name="static") # 添加日志中间件 app.middleware("http")(logging_middleware) diff --git a/frontend/index.html b/frontend/index.html index 42efbe9..b564e6a 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,7 @@ - 甲辰收藏 v1.2.42 + 甲辰收藏 v1.2.43 diff --git a/frontend/src/pages/Home.jsx b/frontend/src/pages/Home.jsx index dc0262b..918009a 100644 --- a/frontend/src/pages/Home.jsx +++ b/frontend/src/pages/Home.jsx @@ -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'} > -
{card.icon}
-
{card.value}
-
{card.label}
+
{card.value}
+
{card.label}
))} + {/* 一尘看板数据 */} +
+
一尘看板今日数据
+
+
+
{yichensStats.total}
+
帖子总数
+
+
+
{yichensStats.deals}
+
出售类
+
+
+
{yichensStats.wants}
+
求购类
+
+
+
{yichensStats.dragons}
+
龙钞
+
+
+
{yichensStats.horses}
+
马钞
+
+
+
{yichensStats.snakes}
+
蛇钞
+
+
+
+ {/* 快捷操作 */}
快捷操作