From 2e28484f669a5335955a546457ccfbff26f2d3f4 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 3 Jul 2020 19:26:04 +0800 Subject: [PATCH] out of memory --- src/forge/Main/CoderRootCommit.js | 74 ++++++++++++++++--------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/src/forge/Main/CoderRootCommit.js b/src/forge/Main/CoderRootCommit.js index 0f0860534..d3ac0e180 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( -
+
{truncateCommitId(`${item.sha}`)} {item.message} - {/* 浏览代码 */}
{item.image_url?:""}
-