forked from Gitlink/forgeplus-react
out of memory
This commit is contained in:
parent
0a2423e648
commit
2e28484f66
|
|
@ -1,8 +1,9 @@
|
|||
import React , { Component } from 'react';
|
||||
import { Spin } from 'antd';
|
||||
import { Spin , Pagination } from 'antd';
|
||||
import { getImageUrl } from 'educoder';
|
||||
import { truncateCommitId } from '../common/util'
|
||||
import SelectBranch from '../Branch/Select';
|
||||
import Nodata from '../Nodata';
|
||||
|
||||
import axios from 'axios';
|
||||
import {Link} from "react-router-dom";
|
||||
|
|
@ -12,18 +13,18 @@ class CoderRootCommit extends Component{
|
|||
super(props)
|
||||
this.state={
|
||||
branch:"master",
|
||||
data:undefined,
|
||||
commitDatas:undefined,
|
||||
dataCount:undefined,
|
||||
limit:50,
|
||||
page:1,
|
||||
isSpin:false
|
||||
isSpining:false
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount=()=>{
|
||||
const { branch , page , limit } = this.state;
|
||||
this.setState({
|
||||
isSpin:true
|
||||
isSpining:true
|
||||
})
|
||||
this.getCommitList( branch , page , limit );
|
||||
}
|
||||
|
|
@ -38,9 +39,12 @@ class CoderRootCommit extends Component{
|
|||
limit
|
||||
}
|
||||
}).then((result)=>{
|
||||
if(result){
|
||||
if(result && result.data){
|
||||
this.setState({
|
||||
isSpining:false
|
||||
})
|
||||
const array = [];
|
||||
result.data && result.data.commits.length > 0 && result.data.commits.map((item,key)=>{
|
||||
result.data.commits && result.data.commits.length > 0 && result.data.commits.map((item,key)=>{
|
||||
array.push({
|
||||
name:item.author && item.author.name,
|
||||
login: item.author && item.author.login,
|
||||
|
|
@ -51,9 +55,9 @@ class CoderRootCommit extends Component{
|
|||
})
|
||||
})
|
||||
this.setState({
|
||||
data:array,
|
||||
commitDatas:array,
|
||||
dataCount:result.data.total_count,
|
||||
isSpin:false
|
||||
isSpining:false
|
||||
})
|
||||
}
|
||||
}).catch((error)=>{console.log(error)})
|
||||
|
|
@ -64,7 +68,7 @@ class CoderRootCommit extends Component{
|
|||
const { page , limit } = this.state;
|
||||
const { getTopCount } = this.props;
|
||||
this.setState({
|
||||
isSpin:true,
|
||||
isSpining:true,
|
||||
branch:value,
|
||||
})
|
||||
this.getCommitList(value , page , limit);
|
||||
|
|
@ -75,28 +79,21 @@ class CoderRootCommit extends Component{
|
|||
const { branch , limit } = this.state;
|
||||
this.getCommitList(branch , page , limit);
|
||||
}
|
||||
|
||||
render(){
|
||||
const { branch , data , dataCount , limit , page , isSpin } = this.state;
|
||||
const { branchs , projectDetail, commit_class } = this.props;
|
||||
const { projectsId } = this.props.match.params;
|
||||
const title =()=>{
|
||||
Paginations =(dataCount,limit,page)=> {
|
||||
if(dataCount > limit){
|
||||
return(
|
||||
<div className="f-wrap-between" style={{alignItems:"center"}}>
|
||||
<span className="font-16">{dataCount}次提交代码({branch})</span>
|
||||
<div className="edu-txt-center pt30 mb30">
|
||||
<Pagination simple defaultCurrent={page} total={dataCount} pageSize={limit} onChange={this.ChangePage}></Pagination>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
render(){
|
||||
const { branch , commitDatas , dataCount , limit , page , isSpining } = this.state;
|
||||
const { branchs , projectDetail, commit_class } = this.props;
|
||||
const { projectsId } = this.props.match.params;
|
||||
|
||||
const Pagination =()=> {
|
||||
if(dataCount > limit){
|
||||
return(
|
||||
<div className="edu-txt-center pt30 mb30">
|
||||
<Pagination simple defaultCurrent={page} total={dataCount} pageSize={limit} onChange={this.ChangePage}></Pagination>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
return(
|
||||
<React.Fragment>
|
||||
<div className={commit_class}>
|
||||
|
|
@ -108,34 +105,41 @@ class CoderRootCommit extends Component{
|
|||
changeBranch={this.changeBranch}
|
||||
></SelectBranch>
|
||||
</div>
|
||||
<Spin spinning={isSpin}>
|
||||
<Spin spinning={isSpining}>
|
||||
<div className="commonBox">
|
||||
<div className="commonBox-title">
|
||||
{title()}
|
||||
<div className="f-wrap-between" style={{alignItems:"center"}}>
|
||||
<span className="font-16">{dataCount}次提交代码({branch})</span>
|
||||
</div>
|
||||
</div>
|
||||
<div className="commitList">
|
||||
{
|
||||
data && data.length > 0 && data.map((item,key)=>{
|
||||
commitDatas && commitDatas.length > 0 ? commitDatas.map((item,k)=>{
|
||||
return(
|
||||
<div>
|
||||
<p className="df">
|
||||
<div key={k}>
|
||||
<p className="f-wrap-alignCenter">
|
||||
<span className="commitKey" style={{marginLeft:0}}>{truncateCommitId(`${item.sha}`)}</span>
|
||||
<span className="flex1 ml20 font-16 color-grey-3">{item.message}</span>
|
||||
{/* <Link to={''} className="color-blue">浏览代码</Link> */}
|
||||
</p>
|
||||
<p className="f-wrap-alignCenter mt15">
|
||||
<Link to={`/users/${item.login}`} className="show-user-link">
|
||||
{item.image_url?<img src={getImageUrl(`images/${item.image_url}`)} alt="" width="28px" height="28px" className="mr15 radius"/>:""}
|
||||
<label className="font-14 color-grey-6" style={{'verticalAlign':'middle'}}>{item.name ?`${item.name}:`:""}提交于 {item.time_from_now}</label>
|
||||
</Link>
|
||||
</p>
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}):<Nodata _html="暂无数据"/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
{ Pagination() }
|
||||
{
|
||||
dataCount > limit ?
|
||||
<div className="edu-txt-center pt30 mb30">
|
||||
<Pagination simple defaultCurrent={page} total={dataCount} pageSize={limit} onChange={this.ChangePage}></Pagination>
|
||||
</div>
|
||||
:""
|
||||
}
|
||||
</Spin>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
|
|
|
|||
Loading…
Reference in New Issue