fix: stop infinite loading spinner when user has no company

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 <noreply@anthropic.com>
This commit is contained in:
Chever John 2026-06-30 01:31:25 +08:00
parent 9ecf3c3179
commit 6b866738be
No known key found for this signature in database
GPG Key ID: 2894D52ED1211DF0
3 changed files with 12 additions and 3 deletions

View File

@ -74,7 +74,10 @@ export function PurchaserDashboard() {
}, []); }, []);
useEffect(() => { useEffect(() => {
if (!auth.company) return; if (!auth.company) {
setLoading(false);
return;
}
// 如果数据已加载,不再重新加载 // 如果数据已加载,不再重新加载
if (dataLoaded && plans.length > 0) { if (dataLoaded && plans.length > 0) {
setLoading(false); setLoading(false);

View File

@ -62,7 +62,10 @@ export function TextileDashboard() {
}, []); }, []);
useEffect(() => { useEffect(() => {
if (!auth.company) return; if (!auth.company) {
setLoading(false);
return;
}
fetchPlans(); fetchPlans();
// 从 localStorage 读取被拒绝的计划ID // 从 localStorage 读取被拒绝的计划ID
const stored = localStorage.getItem(STORAGE_KEYS.textileRejectedPlans); const stored = localStorage.getItem(STORAGE_KEYS.textileRejectedPlans);

View File

@ -69,7 +69,10 @@ export function WashingDashboard() {
}, []); }, []);
useEffect(() => { useEffect(() => {
if (!auth.company) return; if (!auth.company) {
setLoading(false);
return;
}
fetchPlans(); fetchPlans();
}, [auth.company]); }, [auth.company]);