forked from Gitlink/forgeplus-react
代码库-贡献者和语言使用单独接口,detail.json接口不返回这两个数组
This commit is contained in:
parent
e93778b004
commit
2ffa835b84
|
@ -7,10 +7,10 @@ function CloneAddress({http_url , ssh_url , zip_url , tar_url}) {
|
|||
const [ key , setKey ] = useState("HTTP");
|
||||
return (
|
||||
<div className="downMenu">
|
||||
<div style={{borderBottom:"1px solid #eee"}}>
|
||||
<div>
|
||||
<Menu className="urlMenu" selectedKeys={[key]} mode={"horizontal"}>
|
||||
<Menu.Item key="HTTP" onClick={(e)=>{setKey(e.key)}}>HTTP</Menu.Item>
|
||||
<Menu.Item key="SSH" onClick={(e)=>{setKey(e.key)}}>SSH</Menu.Item>
|
||||
{ssh_url && <Menu.Item key="SSH" onClick={(e)=>{setKey(e.key)}}>SSH</Menu.Item>}
|
||||
</Menu>
|
||||
<div className="gitAddressClone">
|
||||
<input type="text" id="copy_rep_content" value={key==="HTTP" ? http_url:ssh_url} />
|
||||
|
@ -18,8 +18,8 @@ function CloneAddress({http_url , ssh_url , zip_url , tar_url}) {
|
|||
</div>
|
||||
</div>
|
||||
<Menu className="edu-txt-center">
|
||||
<Menu.Item><a href={zip_url}>下载 ZIP</a></Menu.Item>
|
||||
<Menu.Item><a href={tar_url}>下载 TAR.GZ</a></Menu.Item>
|
||||
{zip_url && <Menu.Item style={{borderTop:"1px solid #eee"}}><a href={zip_url}>下载 ZIP</a></Menu.Item>}
|
||||
{tar_url && <Menu.Item><a href={tar_url}>下载 TAR.GZ</a></Menu.Item>}
|
||||
</Menu>
|
||||
</div>
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ import './Component.scss';
|
|||
import { getUser } from '../GetData/getData';
|
||||
import axios from 'axios';
|
||||
|
||||
function Contributors({contributors,owner,projectsId,currentLogin}){
|
||||
function Contributors({owner,projectsId,currentLogin}){
|
||||
const [ menuList ,setMenuList ]= useState([]);
|
||||
const [ list , setList ]= useState(undefined);
|
||||
const [ total , setTotal ]= useState(0);
|
||||
|
@ -16,11 +16,18 @@ function Contributors({contributors,owner,projectsId,currentLogin}){
|
|||
const [ isSpin , setIsSpin ] = useState(false);
|
||||
|
||||
useEffect(()=>{
|
||||
if(contributors && contributors.total_count>0){
|
||||
setTotal(contributors.total_count);
|
||||
setList(contributors.list);
|
||||
}
|
||||
},[contributors])
|
||||
getData();
|
||||
},[])
|
||||
|
||||
function getData(){
|
||||
const url = `/${owner}/${projectsId}/contributors.json`;
|
||||
axios.get(url).then(result=>{
|
||||
if(result){
|
||||
setTotal(result.data.total_count);
|
||||
setList(result.data.list);
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
if(login){
|
||||
|
@ -148,15 +155,15 @@ function Contributors({contributors,owner,projectsId,currentLogin}){
|
|||
}
|
||||
|
||||
return(
|
||||
total > 0 ?
|
||||
<div className="halfs">
|
||||
<Link to={`/${owner}/${projectsId}/contribute`} className="font-16 color-ooo hoverA">
|
||||
<span>贡献者</span>
|
||||
{ contributors && contributors.total_count > 0 && <span className="infoCount">{contributors.total_count}</span>}
|
||||
{ total > 0 && <span className="infoCount">{total}</span>}
|
||||
</Link>
|
||||
<div className="attrPerson" onMouseLeave={()=>setVisibleFunc(false)}>
|
||||
{
|
||||
total > 0 ?
|
||||
list.map((item,key)=>{
|
||||
list && list.length>0 && list.map((item,key)=>{
|
||||
return(
|
||||
<Popover content={menu} visible={item.visible} overlayClassName="menuPanels" placement="top">
|
||||
<Link key={key} to={`/${item.login}`}>
|
||||
|
@ -165,10 +172,9 @@ function Contributors({contributors,owner,projectsId,currentLogin}){
|
|||
</Popover>
|
||||
)
|
||||
})
|
||||
:""
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>:""
|
||||
)
|
||||
}
|
||||
export default Contributors;
|
|
@ -1,18 +1,41 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import { FlexAJ } from '../Component/layout';
|
||||
import { Divider } from 'antd';
|
||||
import axios from 'axios';
|
||||
|
||||
function LanguagePower({languages}){
|
||||
function LanguagePower({owner,projectsId}){
|
||||
const [ array , setArray ] = useState(undefined);
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
if(languages){
|
||||
let arr = [];
|
||||
Object.keys(languages).map((item,key)=>{
|
||||
arr.push({name:item,percent:languages[item],color:getColor()});
|
||||
})
|
||||
setArray(arr);
|
||||
}
|
||||
},[languages])
|
||||
getData();
|
||||
},[])
|
||||
|
||||
function getData(){
|
||||
const url = `/${owner}/${projectsId}/languages.json`;
|
||||
axios.get(url).then(result=>{
|
||||
if(result){
|
||||
let languages = result.data;
|
||||
if(languages){
|
||||
let arr = [];
|
||||
Object.keys(languages).map((item,key)=>{
|
||||
arr.push({name:item,percent:languages[item],color:getColor()});
|
||||
})
|
||||
setArray(arr);
|
||||
}
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
|
||||
// useEffect(()=>{
|
||||
// if(languages){
|
||||
// let arr = [];
|
||||
// Object.keys(languages).map((item,key)=>{
|
||||
// arr.push({name:item,percent:languages[item],color:getColor()});
|
||||
// })
|
||||
// setArray(arr);
|
||||
// }
|
||||
// },[languages])
|
||||
|
||||
function getColor(){
|
||||
let str = "#";
|
||||
|
@ -24,7 +47,9 @@ function LanguagePower({languages}){
|
|||
return str;
|
||||
}
|
||||
return(
|
||||
(array && array.length > 0) ?
|
||||
<div>
|
||||
<Divider />
|
||||
<p className="font-16 color-ooo aboutSubTitle">开发语言</p>
|
||||
<div className="progress">
|
||||
{
|
||||
|
@ -47,8 +72,7 @@ function LanguagePower({languages}){
|
|||
}
|
||||
</FlexAJ>
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>:""
|
||||
)
|
||||
}
|
||||
export default LanguagePower;
|
|
@ -319,9 +319,9 @@ function CoderDepot(props){
|
|||
const downloadMenu = (
|
||||
<CloneAddress
|
||||
http_url={projectDetail && projectDetail.clone_url}
|
||||
ssh_url = {projectDetail && projectDetail.ssh_url}
|
||||
zip_url={zip_url}
|
||||
tar_url={tar_url}
|
||||
ssh_url = {(projectDetail && props && props.platform) && projectDetail.ssh_url}
|
||||
zip_url={(props && props.platform) && zip_url}
|
||||
tar_url={(props && props.platform) && tar_url}
|
||||
showNotification={props.showNotification}/>
|
||||
)
|
||||
// 确认修改简介、website、实践课程链接
|
||||
|
@ -582,17 +582,9 @@ function CoderDepot(props){
|
|||
</React.Fragment>
|
||||
}
|
||||
{/* 贡献者 */}
|
||||
{
|
||||
projectDetail && projectDetail.contributors && projectDetail.contributors.total_count >0 &&
|
||||
<Contributors contributors={projectDetail.contributors} owner={owner} projectsId={projectsId} />
|
||||
}
|
||||
<Contributors owner={owner} projectsId={projectsId} />
|
||||
{/* 语言 */}
|
||||
{ projectDetail && projectDetail.languages &&
|
||||
<React.Fragment>
|
||||
<Divider />
|
||||
<LanguagePower languages={projectDetail.languages}/>
|
||||
</React.Fragment>
|
||||
}
|
||||
<LanguagePower owner={owner} projectsId={projectsId}/>
|
||||
</Gap>
|
||||
</ShortWidth>
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ class CoderRootCommit extends Component{
|
|||
|
||||
render(){
|
||||
const { commitDatas , dataCount , limit , page , isSpining , branchList } = this.state;
|
||||
const { projectDetail, commit_class , defaultBranch } = this.props;
|
||||
const { projectDetail, commit_class , defaultBranch , platform } = this.props;
|
||||
const { projectsId , owner , branchName } = this.props.match.params;
|
||||
let branch = returnbar(branchName || defaultBranch);
|
||||
return(
|
||||
|
@ -159,7 +159,16 @@ class CoderRootCommit extends Component{
|
|||
<div className="commitList-item f-wrap-between">
|
||||
<div>
|
||||
<AlignTop>
|
||||
<div className="commitDesc"><Link to={`/${owner}/${projectsId}/commits/${truncateCommitId(`${item.sha}`)}`} className="font-14 color-grey-3 font-bd"><RenderHtml value={item.message}/></Link></div>
|
||||
<div className="commitDesc">
|
||||
{
|
||||
platform ?
|
||||
<Link to={`/${owner}/${projectsId}/commits/${truncateCommitId(`${item.sha}`)}`} className="font-14 color-grey-3 font-bd">
|
||||
<RenderHtml value={item.message}/>
|
||||
</Link>
|
||||
:
|
||||
<RenderHtml value={item.message}/>
|
||||
}
|
||||
</div>
|
||||
</AlignTop>
|
||||
<p className="f-wrap-alignCenter mt15 pb5">
|
||||
<User
|
||||
|
@ -176,7 +185,12 @@ class CoderRootCommit extends Component{
|
|||
<div>
|
||||
<span className="treecopy-cont shadow">
|
||||
<img src={Tree} alt="sha" width={"16px"}/>
|
||||
<Link to={`/${owner}/${projectsId}/commits/${truncateCommitId(`${item.sha}`)}`}>{truncateCommitId(`${item.sha}`)}</Link>
|
||||
{
|
||||
platform ?
|
||||
<Link to={`/${owner}/${projectsId}/commits/${truncateCommitId(`${item.sha}`)}`}>{truncateCommitId(`${item.sha}`)}</Link>
|
||||
:
|
||||
<span style={{color:"#466AFF",cursor:"default"}}>{truncateCommitId(`${item.sha}`)}</span>
|
||||
}
|
||||
<input type="text" id={`value${k}`} value={`${truncateCommitId(`${item.sha}`)}`}/>
|
||||
</span>
|
||||
<CopyTool beforeText="复制commit id" afterText="复制成功" inputId={`value${k}`}/>
|
||||
|
|
|
@ -109,7 +109,7 @@ ul,ol,dl{
|
|||
width: 49rem;
|
||||
overflow: hidden;
|
||||
white-space: normal;
|
||||
&:hover{
|
||||
& a:hover{
|
||||
text-decoration: underline;
|
||||
& .markdown-body{
|
||||
color: #466AFF;
|
||||
|
|
Loading…
Reference in New Issue