From 6b866738bee7cb5877abb86f4449f9502cf81455 Mon Sep 17 00:00:00 2001 From: Chever John Date: Tue, 30 Jun 2026 01:31:25 +0800 Subject: [PATCH] fix: stop infinite loading spinner when user has no company MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dashboard pages hung on "加载仪表盘数据..." when auth.company was null (e.g. admin user). Now sets loading=false immediately when no company is present, so the page renders instead of spinning forever. Co-Authored-By: Claude --- src/pages/purchaser/Dashboard.tsx | 5 ++++- src/pages/textile/Dashboard.tsx | 5 ++++- src/pages/washing/Dashboard.tsx | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pages/purchaser/Dashboard.tsx b/src/pages/purchaser/Dashboard.tsx index d87675d..02ad8fb 100644 --- a/src/pages/purchaser/Dashboard.tsx +++ b/src/pages/purchaser/Dashboard.tsx @@ -74,7 +74,10 @@ export function PurchaserDashboard() { }, []); useEffect(() => { - if (!auth.company) return; + if (!auth.company) { + setLoading(false); + return; + } // 如果数据已加载,不再重新加载 if (dataLoaded && plans.length > 0) { setLoading(false); diff --git a/src/pages/textile/Dashboard.tsx b/src/pages/textile/Dashboard.tsx index 0bb7c38..c6d2e66 100644 --- a/src/pages/textile/Dashboard.tsx +++ b/src/pages/textile/Dashboard.tsx @@ -62,7 +62,10 @@ export function TextileDashboard() { }, []); useEffect(() => { - if (!auth.company) return; + if (!auth.company) { + setLoading(false); + return; + } fetchPlans(); // 从 localStorage 读取被拒绝的计划ID const stored = localStorage.getItem(STORAGE_KEYS.textileRejectedPlans); diff --git a/src/pages/washing/Dashboard.tsx b/src/pages/washing/Dashboard.tsx index 7d3f682..2d65295 100644 --- a/src/pages/washing/Dashboard.tsx +++ b/src/pages/washing/Dashboard.tsx @@ -69,7 +69,10 @@ export function WashingDashboard() { }, []); useEffect(() => { - if (!auth.company) return; + if (!auth.company) { + setLoading(false); + return; + } fetchPlans(); }, [auth.company]);