diff --git a/src/forge/Main/CoderRootCommit.js b/src/forge/Main/CoderRootCommit.js index 0f086053..d3ac0e18 100644 --- a/src/forge/Main/CoderRootCommit.js +++ b/src/forge/Main/CoderRootCommit.js @@ -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( -
- {dataCount}次提交代码({branch}) +
+
) } + } + + 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( -
- -
- ) - } - } return(
@@ -108,34 +105,41 @@ class CoderRootCommit extends Component{ changeBranch={this.changeBranch} >
- +
- {title()} +
+ {dataCount}次提交代码({branch}) +
{ - data && data.length > 0 && data.map((item,key)=>{ + commitDatas && commitDatas.length > 0 ? commitDatas.map((item,k)=>{ return( -
-

+

+

{truncateCommitId(`${item.sha}`)} {item.message} - {/* 浏览代码 */}

{item.image_url?:""} -

+

) - }) + }): }
- { Pagination() } + { + dataCount > limit ? +
+ +
+ :"" + }