diff --git a/src/forge/projectHome/explore/index.jsx b/src/forge/projectHome/explore/index.jsx index 2f1fec519..c97d4a284 100644 --- a/src/forge/projectHome/explore/index.jsx +++ b/src/forge/projectHome/explore/index.jsx @@ -19,6 +19,10 @@ import img16 from '../image/icon16.png'; import { rollingButton } from "../../../components/button"; const { Search } = Input; function ProjectHomePage(props) { + const {mygetHelmetapi} = props; + const {common} = mygetHelmetapi || {}; + // const {governance="http://172.16.6.252:10010"} = common || {}; + const governance=(window.location.hostname=='172.16.6.250'||window.location.hostname=='localhost')?'http://172.16.6.252:10002':'http://27.122.114.160:4000/governanceAdmin' const carouselEL = createRef() const [current, setCurrent] = useState(0); const [cateList, setCateList] = useState(undefined); @@ -60,11 +64,18 @@ function ProjectHomePage(props) { const topicsLength = topicsByCateId && topicsByCateId.length const LIMIT = !topicsLength ? 30 : 25; + const trustLevelMap = { + '-1':'待治理', + 0: '不可信', + 1: '高度可信', + 2: '可信', + } + useEffect(() => { getCate(); // getList(); getCateTopic(); - document.title = '菌用开源软件仓库'; + document.title = '军用开源软件仓库'; // 获取总数 getInitCount(); }, []) @@ -114,14 +125,43 @@ function ProjectHomePage(props) { params.language_id = topicId.split(",") params.topic_id = undefined } - axios.get(url, { params }).then(result => { if (result && result.data) { setTotal(result.data.total_count); - setProjectsList(result.data.projects); - setIsSpin(false); + // 遍历projects,请求供应链治理接口 获取可信等级 + const projectsWithTrustLevel = result.data.projects.map(async project => { + try { + const response = await axios.post(`${governance}/detect/software/trustPage`, + { + softwareName: project.identifier, + size: 1, + current: 1 + } + ); + const records=response.data.data.records||[] + const trustLevel = records.length > 0 ? records[0].isTrust : null; + return { + ...project, + trustLevel: trustLevel|| '-1' // 假设返回的数据中有一个 trustLevel 字段 + }; + } catch (error) { + return { + ...project, + trustLevel: '-1' // 如果请求失败,设置 trustLevel 为 null 或其他适当的值 + }; + } + }); + // 等待所有请求完成 + Promise.all(projectsWithTrustLevel).then(updatedProjects => { + setProjectsList(updatedProjects); + setIsSpin(false); + }).catch(error => { + setIsSpin(false); + }); } - }).catch(error => { }) + }).catch(error => { + setIsSpin(false); + }); } function getList() { @@ -141,8 +181,8 @@ function ProjectHomePage(props) {