From fa240afad804ffb601eb24bcdd3ef8317d85fc23 Mon Sep 17 00:00:00 2001 From: D-Robotics Date: Thu, 2 Jul 2026 22:26:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E6=8A=A5=E5=91=8A=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E9=A1=B5=E6=B7=BB=E5=8A=A0HTML=20Dashboard=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/reports/ReportsView.tsx | 215 ++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 frontend/src/components/reports/ReportsView.tsx diff --git a/frontend/src/components/reports/ReportsView.tsx b/frontend/src/components/reports/ReportsView.tsx new file mode 100644 index 0000000..875ca15 --- /dev/null +++ b/frontend/src/components/reports/ReportsView.tsx @@ -0,0 +1,215 @@ +import { useState, useEffect } from 'react'; +import { useLocation } from 'react-router-dom'; +import { CheckCircle2, XCircle, Eye, FileText, ExternalLink } from 'lucide-react'; +import { PRODUCTS } from '../layout/navConfig'; + +interface Report { + task_id: string; + task_name: string; + product: string; + total_runs: number; + pass: number; + fail: number; + result: string; + started_at: string; + finished_at: string; + thumbnail: string | null; +} + +interface ReportDetail extends Report { + results: Array<{ + name: string; + desc: string; + status: string; + duration: string; + module: string; + }>; + logs: Array<{ ts: string; level: string; msg: string }>; + screenshots: string[]; + html_report?: string; +} + +export default function ReportsView() { + const location = useLocation(); + const platform = location.pathname.startsWith('/dcloud') ? 'dcloud' : 'robogo'; + const [reports, setReports] = useState([]); + const [detail, setDetail] = useState(null); + + useEffect(() => { + fetch(`/api/reports?product=${platform}`) + .then(r => r.json()) + .then(setReports) + .catch(console.error); + }, []); + + const viewReport = async (tid: string) => { + const res = await fetch(`/api/reports/${tid}`); + if (res.ok) setDetail(await res.json()); + }; + + return ( +
+

+ 报告中心 ({reports.length}) +

+ + {!detail ? ( +
+ + + + + + + + + + + + + {reports.length === 0 && ( + + + + )} + {reports.map(r => ( + + + + + + + + + ))} + +
任务产品结果通过/总计时间操作
+ 暂无报告 +
{r.task_name}{PRODUCTS[r.product] || r.product} +
+ {r.result === 'PASS' ? ( + + ) : ( + + )} + + {r.result === 'PASS' ? '通过' : '失败'} + +
+
{r.pass}/{r.total_runs} + {r.finished_at?.split('T')[1]?.slice(0, 5) || '-'} + + +
+
+ ) : ( +
+ + +
+
+
+

{detail.task_name}

+

Product: {PRODUCTS[detail.product] || detail.product}

+
+
+ {detail.result === 'PASS' ? '通过' : '失败'} +
+
+ +
+
+
{detail.total_runs}
+
总计运行
+
+
+
{detail.pass}
+
通过
+
+
+
{detail.fail}
+
失败
+
+
+
+ {detail.total_runs > 0 ? Math.round(detail.pass / detail.total_runs * 100) : 0}% +
+
通过率
+
+
+ + {detail.html_report && ( + + )} + + {detail.results.length > 0 && ( +
+
+ + 测试结果 +
+
+ {detail.results.map((r, i) => ( +
+
+
{r.desc || r.name}
+
{r.module}
+
+
+ {r.duration} + {r.status === 'PASS' ? ( + + ) : ( + + )} +
+
+ ))} +
+
+ )} + + {detail.screenshots.length > 0 && ( +
+
截图
+
+ {detail.screenshots.map(s => ( + {s} + ))} +
+
+ )} +
+
+ )} +
+ ); +} \ No newline at end of file