From 81c8bb6e87aa42d46297fc5a652389abe05fabba Mon Sep 17 00:00:00 2001 From: amypeng Date: Mon, 8 Jun 2026 20:08:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=A7=AF=E5=88=86=E7=BD=AE?= =?UTF-8?q?=E9=A1=B6=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 首页积分置顶项目 --- .../homepage/component/projectByNSCC.jsx | 135 ++++++++++++++---- .../Information/Pages/homepage/index.scss | 11 +- src/forge/Information/api.js | 7 + src/forge/Information/fetch.js | 2 +- 4 files changed, 128 insertions(+), 27 deletions(-) diff --git a/src/forge/Information/Pages/homepage/component/projectByNSCC.jsx b/src/forge/Information/Pages/homepage/component/projectByNSCC.jsx index b35d69ec9..552713974 100644 --- a/src/forge/Information/Pages/homepage/component/projectByNSCC.jsx +++ b/src/forge/Information/Pages/homepage/component/projectByNSCC.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useRef, useState } from 'react'; import '../index.scss'; -import { getProjectListByScore, getProjectsTypeLists } from '../../../api'; +import { getProjectListByScore, getProjectsTypeLists, getPointsProjectList } from '../../../api'; import { Carousel, Divider, Pagination, Spin } from 'antd'; import Nodata from '../../../../Nodata'; import Slider from 'react-slick'; @@ -16,6 +16,7 @@ function TypeCarousel({pageSize=4, list=[], typeId, onClick}) { const start = i * pageSize; const end = start + pageSize; pages.push(list.slice(start, end)); + console.log('ppp', pages) } return {pages.map((page, index)=>{ @@ -24,6 +25,7 @@ function TypeCarousel({pageSize=4, list=[], typeId, onClick}) { {page.map((item, i) => { const order = index*pageSize+i const iconName = { + "精选项目": "icon-jingxuanxiangmu", "并行计算框架": "icon-binghangjisuankuangjia", "异构数据库": "icon-yigoushujuku", "性能基准与评测": "icon-xingnengjizhunyupingce", @@ -55,6 +57,7 @@ function Project({ data, nsccTitle }) { const [typeList, setTypeList] = useState([]); const [typeId, setTypeId] = useState(undefined); const [lists, setLists] = useState([]); + const [topList, setTopList] = useState([]); const [loading, setLoading] = useState(false); const [page, setPage] = useState(1); const [total, setTotal] = useState(0); @@ -93,20 +96,41 @@ function Project({ data, nsccTitle }) { }, []); useEffect(() => { - id && getProjectsTypeLists(id, { - pageNum: 1, - pageSize: 100, - }).then(result => { - if (result) { - const rows = result.data.rows; - rows[0] && setTypeId(rows[0].id) - setTypeList(rows); + async function fetchTypeData() { + let typeList = []; + let typeId = null; + if(id) { + let res = await getPointsProjectList(id); + if(res && Array.isArray(res.data.data) && res.data.data.length){ + setTopList(res.data.data); + typeList.push({id: -1, zoneId: id, name: '精选项目'}); + typeId = -1; + } + + getProjectsTypeLists(id, { + pageNum: 1, + pageSize: 100, + }).then(result => { + if (result) { + const rows = result.data.rows; + if(Array.isArray(rows) && rows.length) { + typeList = [...typeList, ...rows]; + setTypeList(typeList); + if (typeId === null) { + setTypeId(rows[0].id); + } else { + setTypeId(typeId); + } + } + } + }).catch(() => { }) } - }).catch(() => { }) + } + fetchTypeData(); }, [id]) useEffect(() => { - if (typeId) { + if (typeId && typeId !== -1) { // 非置顶项目查询数据 setLoading(true); getProjectListByScore(id, { pageNum: page, @@ -168,25 +192,86 @@ function Project({ data, nsccTitle }) { } + const topDetail = (className="online_detail", i, index, length) => { + const { extra: { } } = i || {} + return
window.open(i.projectURL)}> +
+ {i.projectProperties && i.projectProperties.name} +
+
+ {i.projectProperties.description || "暂无描述"} +
+
+
    + {i.projectProperties.language &&
  • {i.projectProperties.language}
  • } + { + i.projectProperties && i.projectProperties.topics && + i.projectProperties.topics.split(",").map(t => { + return ( +
  • {t}
  • + ) + }) + } +
+
+

+

+ {i.projectProperties.language && ( + <> + {i.projectProperties.language} + + + )} + {i.projectProperties.timeAgo && 更新于{i.projectProperties.timeAgo}} +
+
+ 赞{i.projectProperties.praisesCount} + fork{i.projectProperties.forkedCount} +
+

+
+ } + return
{nsccTitle(homepageProjectTitle, 0.1, "font-bd font-30 mb50 align task-hide")}
{setTypeId(id); setPage(1)}}/> - -
- {lists.slice(0, 3).map((i, index)=>{ - return projectDetail("online_detail", i, index, 3) - })} -
- {lists.length > 3 &&
- {lists.slice(3).map((i, index)=>{ - return projectDetail("second_detail", i, index, lists.slice(4).length) - })} -
} - {setPage(page)}} className='center mt30'/> - {!loading && lists.length === 0 && } -
+ { + typeId !== -1 && + +
+ {lists.slice(0, 3).map((i, index)=>{ + return projectDetail("online_detail", i, index, 3) + })} +
+ {lists.length > 3 &&
+ {lists.slice(3).map((i, index)=>{ + return projectDetail("second_detail", i, index, lists.slice(4).length) + })} +
} + {setPage(page)}} className='center mt30'/> + {!loading && lists.length === 0 && } +
+ } + { + typeId === -1 && + +
+ {topList.slice(0, 3).map((i, index)=>{ + return topDetail("online_detail", i, index, 3) + })} +
+ {lists.length > 3 &&
+ {topList.slice(3).map((i, index)=>{ + return topDetail("second_detail", i, index, lists.slice(4).length) + })} +
} + {setPage(page)}} className='center mt30'/> + {!loading && lists.length === 0 && } +
+ } +
diff --git a/src/forge/Information/Pages/homepage/index.scss b/src/forge/Information/Pages/homepage/index.scss index 49ec7840a..9b054ce4c 100644 --- a/src/forge/Information/Pages/homepage/index.scss +++ b/src/forge/Information/Pages/homepage/index.scss @@ -984,6 +984,11 @@ padding: 22px 20px 20px 20px; border-radius:15px; box-shadow:0px 0px 12px rgba(33, 73, 212, 0.1); + .topitem{ + background-color: rgba(0, 0, 0, 0.08); + padding: 4px 8px; + border-radius: 4px; + } &:hover{ background-image: url('./image/projectBk2.png'); span, div{ @@ -997,6 +1002,9 @@ background-color:rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.5); } + .topitem{ + background-color: rgba(255, 255, 255, 0.12); + } } } .second_detail{ @@ -1190,4 +1198,5 @@ } } } -} \ No newline at end of file +} + diff --git a/src/forge/Information/api.js b/src/forge/Information/api.js index f29c9ac2e..9854422f7 100644 --- a/src/forge/Information/api.js +++ b/src/forge/Information/api.js @@ -704,3 +704,10 @@ export function getPointsDocList(id){ }) } +// 获取文章列表 +export function getPointsProjectList(id){ + return fetch({ + url:`/zone/zoneFront/getTopProject/${id}`, + method: 'get', + }) +} diff --git a/src/forge/Information/fetch.js b/src/forge/Information/fetch.js index b7b23f9ea..766f2c49a 100644 --- a/src/forge/Information/fetch.js +++ b/src/forge/Information/fetch.js @@ -15,7 +15,7 @@ function beforeFetch(actionUrl){ service.interceptors.request.use(request => { let deptId = sessionStorage.getItem('deptId'); - // request.headers.Authorization = '8786c89c803fc2420f75c19895f0cee794b6f9a3' + request.headers.Authorization = '26569459fc34087176a576216e360cd1d27de78e' if (deptId) { // 用于权限区分 request.headers['Dept-Id'] = deptId