From b0942f3e61b6712afb12048eb4aa6cb6742cd463 Mon Sep 17 00:00:00 2001 From: selfrelease Date: Sat, 1 Aug 2026 16:27:03 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Dashboard=20complianceScore=20=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=90=8D=E4=B8=8D=E5=8C=B9=E9=85=8D=E5=8F=8A=E7=BC=BA?= =?UTF-8?q?=E5=B0=91=E5=8F=AF=E9=80=89=E9=93=BE=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - complianceScore.overallScore → fallback to totalScore - complianceScore.levelLabel → fallback to summary - complianceScore.suggestions 加可选链守卫 - data.todos 加可选链守卫 - data.topRisks 加空数组兜底 --- frontend/src/pages/Dashboard.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/src/pages/Dashboard.tsx b/frontend/src/pages/Dashboard.tsx index 8a7bc86..3c99dc6 100644 --- a/frontend/src/pages/Dashboard.tsx +++ b/frontend/src/pages/Dashboard.tsx @@ -136,8 +136,8 @@ export default function Dashboard() { }) } - const riskTodos = data?.todos.filter((t) => t.type === 'CONTRACT' || t.type === 'TERMINATION' || t.type === 'ONBOARDING' || t.type === 'RETIREMENT') || [] - const taskTodos = data?.todos.filter((t) => t.type === 'MONTHLY' || t.type === 'SALARY') || [] + const riskTodos = data?.todos?.filter((t) => t.type === 'CONTRACT' || t.type === 'TERMINATION' || t.type === 'ONBOARDING' || t.type === 'RETIREMENT') || [] + const taskTodos = data?.todos?.filter((t) => t.type === 'MONTHLY' || t.type === 'SALARY') || [] const filteredTodos = activeTab === 'risk' ? riskTodos : taskTodos if (isLoading) { @@ -270,7 +270,7 @@ export default function Dashboard() { @@ -279,13 +279,13 @@ export default function Dashboard() {
- {complianceScore.overallScore} - {complianceScore.levelLabel} + {complianceScore?.overallScore ?? complianceScore?.totalScore ?? 0} + {complianceScore?.levelLabel ?? complianceScore?.summary ?? ''}
{/* 5 维度评分 */}
- {complianceScore.dimensions.map((dim: any) => ( + {complianceScore?.dimensions?.map((dim: any) => (
= 85 ? 'bg-safe' : dim.score >= 60 ? 'bg-warning' : 'bg-danger'}`} /> @@ -302,7 +302,7 @@ export default function Dashboard() { {/* AI 建议卡片流 */} - {complianceScore.suggestions.length > 0 && ( + {complianceScore?.suggestions && complianceScore.suggestions.length > 0 && (
@@ -547,8 +547,8 @@ export default function Dashboard() {
- {data.topRisks.filter(r => r.type === drillDownType).length > 0 ? ( - data.topRisks.filter(r => r.type === drillDownType).map((r) => ( + {(data.topRisks || []).filter(r => r.type === drillDownType).length > 0 ? ( + (data.topRisks || []).filter(r => r.type === drillDownType).map((r) => (