diff --git a/src/forge/Main/CoderDepot.jsx b/src/forge/Main/CoderDepot.jsx index f50c134a3..e6c619c00 100644 --- a/src/forge/Main/CoderDepot.jsx +++ b/src/forge/Main/CoderDepot.jsx @@ -23,6 +23,7 @@ import Nodata from '../Nodata'; import Invite from './sub/Invite'; import CheckProfile from '../Component/ProfileModal/Profile'; import RenderHtml from '../../components/render-html'; +import Badge from "./sub/Badge"; /** * projectDetail.type:0是托管项目,1是镜像项目,2是同步镜像项目(为2时不支持在线创建、在线上传、在线修改、在线删除、创建合并请求等功能) */ @@ -80,6 +81,13 @@ function CoderDepot(props){ const distribution = details && details.type != 2 && (details.permission === "Admin" || details.permission === "Owner" || details.permission === "Manager"); const { bannerList } = props; + + // test data + const badges = {badge:[{ "login": "many_stars", "image_url": "https://www.gitlink.org.cn/system/lets/letter_avatars/2/J/236_194_58/120.png", "description": "test description1"}, {"login": "many_stars", "image_url": "https://www.gitlink.org.cn/system/lets/letter_avatars/2/X/181_166_38/120.png", "description": "test description2"}], total_count: 3} + console.log(badges.badge) + console.log(badges.total_count) + + useEffect(()=>{ if(bannerList && bannerList.length>0){ let a = bannerList.filter(i=>i.menu_name === "pulls"); @@ -550,6 +558,11 @@ function CoderDepot(props){ } + + { + badges && badges.total_count >0 && + + } { lesson_url &&
diff --git a/src/forge/Main/Index.scss b/src/forge/Main/Index.scss index 5f3692929..aebb9a361 100644 --- a/src/forge/Main/Index.scss +++ b/src/forge/Main/Index.scss @@ -508,4 +508,22 @@ margin-left: 0px; } } +} + +.attrBadge{ + padding-top: 12px; + display: flex; + flex-wrap: wrap; + padding-bottom: 2px; + a{ + margin: 0px 17px 10px 0px; + img{ + border-radius: 50%; + width: 40px; + height: 40px; + } + &:nth-child(5n){ + margin-right: 0px; + } + } } \ No newline at end of file diff --git a/src/forge/Main/sub/Badge.jsx b/src/forge/Main/sub/Badge.jsx new file mode 100644 index 000000000..01071754d --- /dev/null +++ b/src/forge/Main/sub/Badge.jsx @@ -0,0 +1,103 @@ +import React, { useEffect, useState } from 'react'; +import { AlignCenter , FlexAJ } from '/home/gitlink/forgeplus/public/react/forgeplus-react/src/forge/Component/layout'; +import { Link } from 'react-router-dom'; +import { Popover , Spin , Button } from 'antd'; +import { getImageUrl } from 'educoder'; +import '../../Component/Component.scss'; + + + + +// projectDetail && projectDetail.contributors && projectDetail.contributors.total_count >0 && +// ? + +function Badge({badges,owner}){ + const [ list , setList ]= useState(undefined); + const [ total , setTotal ]= useState(0); + const [ menu , setMenu ] = useState(""); + const [ login , setLogin ] = useState(undefined); + const [ badge , setBadge ] = useState(undefined); + + useEffect(()=>{ + if(badges && badges.total_count>0){ + setTotal(badges.total_count); + setList(badges.badge); + } + },[badges]) + + useEffect(()=>{ + setMenusFunc(badge); + },[badge]) + + + function setMenusFunc(data){ + if(data){ + let ele = ( + + +
+ {data.name} + { data.description && {data.description} } +
+
+ ) + setMenu(ele); + } + } + + + function setVisibleFunc(flag,l,index){ + if(l !== badge){ + setBadge(l); + } + var lx = list.concat(); + lx.map(i=>i.visible =false); + if(flag){ + lx[index].visible = flag; + } + lx.splice(); + setList(lx); + } + + // { + // "list": [ + // { + // "login": "many_stars", + // "image_url": "User", + // "description": "test description" + // }, + // { + // "login": "many_stars", + // "image_url": "User", + // "description": "test description" + // } + // ], + // "total_count": 2 + // } + return( +
+ + 徽章 + { badges && badges.total_count > 0 && {badges.total_count}} + + +
setVisibleFunc(false)}> + { + total > 0 ? + list.map((item,key)=>{ + return( + + + setVisibleFunc(true,item,key)}/> + + + ) + }) + :"" + } +
+
+ ) +} +//{getImageUrl(`/${item.image_url}`)} +export default Badge; \ No newline at end of file diff --git a/src/forge/users/Index.scss b/src/forge/users/Index.scss index 8139ebaec..caa5b81db 100644 --- a/src/forge/users/Index.scss +++ b/src/forge/users/Index.scss @@ -239,4 +239,36 @@ ul.ant-menu.menuStyle{ content:""; } } +} + +.attrBadge{ + padding-top: 12px; + display: flex; + flex-wrap: wrap; + padding-bottom: 2px; + a{ + margin: 0px 17px 10px 0px; + img{ + border-radius: 50%; + width: 40px; + height: 40px; + } + &:nth-child(5n){ + margin-right: 0px; + } + } +} + + +.infoCount{ + display: inline-block; + width: 24px; + text-align: center; + height: 24px; + line-height: 24px; + background-color:rgba(153, 153, 153, 0.13);; + color:#666; + border-radius: 12px; + margin-left: 6px; + font-size: 12px; } \ No newline at end of file diff --git a/src/forge/users/Infos.js b/src/forge/users/Infos.js index 1cd3969de..b1bed641e 100644 --- a/src/forge/users/Infos.js +++ b/src/forge/users/Infos.js @@ -13,6 +13,10 @@ import './Index.scss'; import Loadable from "react-loadable"; import Loading from "../../Loading"; +import Badge from "../Main/sub/Badge"; + +//test data +const badges = {badge:[{ "login": "many_stars", "image_url": "https://testforgeplus.trustie.net//system/lets/letter_avatars/2/G/178_217_57/120.png", "description": "test description1"}, {"login": "many_stars", "image_url": "https://testforgeplus.trustie.net//images/avatars/User/36480?t=1686645429", "description": "test description2"}], total_count: 3} const UpdateInfo = Loadable({ loader: () => import("./Material/Index"), @@ -276,6 +280,12 @@ class Infos extends Component { :"" }
+ {/* 徽章 */} + { + badges && badges.total_count >0 && + + } +