From 8ff0ee3475574ea95eb6916a483bce72b1557ae3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Allen=20Zhang=20=28=E5=BC=A0=E6=B6=9B=29?= Date: Tue, 8 Oct 2024 10:49:40 +0800 Subject: [PATCH] feat: update --- .../index/projects/[id]/commits/[sha].tsx | 63 +++++++------------ 1 file changed, 24 insertions(+), 39 deletions(-) diff --git a/packages/canyon-platform/src/pages/index/projects/[id]/commits/[sha].tsx b/packages/canyon-platform/src/pages/index/projects/[id]/commits/[sha].tsx index ae4d4f81..b3eea9f9 100755 --- a/packages/canyon-platform/src/pages/index/projects/[id]/commits/[sha].tsx +++ b/packages/canyon-platform/src/pages/index/projects/[id]/commits/[sha].tsx @@ -7,9 +7,10 @@ import { useSearchParams, } from "react-router-dom"; -import CanyonReport from "../../../../../components/CanyonReport"; -import { GetProjectByIdDocument } from "../../../../../helpers/backend/gen/graphql.ts"; +// import CanyonReport from "../../../../../components/CanyonReport"; +import { GetProjectByIdDocument } from "@/helpers/backend/gen/graphql.ts"; import { getCoverageSummaryMapService, handleSelectFile } from "./helper"; +import Report from "canyon-report/src/components"; const { useToken } = theme; const Sha = () => { @@ -44,8 +45,6 @@ const Sha = () => { ); const [activatedPath, setActivatedPath] = useState(sprm.get("path") || ""); - const [mainData, setMainData] = useState(false); - useEffect(() => { const params = new URLSearchParams(); if (sprm.get("report_id")) { @@ -58,28 +57,7 @@ const Sha = () => { // 将参数拼接到路径中 const pathWithParams = `${currentPathname}?${params.toString()}${location.hash}`; - nav(pathWithParams); - - if (activatedPath.includes(".")) { - handleSelectFile({ - filepath: activatedPath, - reportID: sprm.get("report_id") || "", - sha: prm.sha || "", - projectID: prm.id || "", - mode: sprm.get("mode") || "", - }).then((r) => { - if (r.fileCoverage) { - // console.log(r) - setMainData(r); - } else { - setMainData(false); - } - }); - } else { - // console.log('设么也不做'); - setMainData(false); - } }, [activatedPath]); return ( @@ -91,20 +69,27 @@ const Sha = () => { }} > <> - {getProjectByIdDocumentData?.getProjectByID.language === - "JavaScript" && ( - { - setActivatedPath(v.path); - }} - /> - )} + { + setActivatedPath(val); + return handleSelectFile({ + filepath: val, + reportID: sprm.get("report_id") || "", + sha: prm.sha || "", + projectID: prm.id || "", + mode: sprm.get("mode") || "", + }).then((res) => { + console.log(res); + return { + fileCoverage: res.fileCoverage, + fileContent: res.fileContent, + }; + }); + }} + value={activatedPath} + />