From 2dca31f6c6541e35ec5443a13248ca525461d40f Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 3 Jul 2020 16:32:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B6=E9=83=A8count?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Main/CoderRootCommit.js | 2 + src/forge/Main/CoderRootDirectory.js | 13 ++-- src/forge/Main/CoderRootIndex.js | 76 ++++++++++++++++++++---- src/forge/Main/CoderRootTag.js | 3 - src/forge/Main/Detail.js | 34 +---------- src/forge/Main/DetailTop.js | 16 ++--- src/forge/Newfile/Index.js | 2 - src/forge/Newfile/UserSubmitComponent.js | 4 +- src/forge/Newfile/upload_file.js | 4 -- src/forge/Order/New.js | 4 +- 10 files changed, 82 insertions(+), 76 deletions(-) diff --git a/src/forge/Main/CoderRootCommit.js b/src/forge/Main/CoderRootCommit.js index 01997d078..0f0860534 100644 --- a/src/forge/Main/CoderRootCommit.js +++ b/src/forge/Main/CoderRootCommit.js @@ -62,11 +62,13 @@ class CoderRootCommit extends Component{ // 切换分支 search:tag为根据标签搜索 changeBranch=(value)=>{ const { page , limit } = this.state; + const { getTopCount } = this.props; this.setState({ isSpin:true, branch:value, }) this.getCommitList(value , page , limit); + getTopCount && getTopCount(value); } ChangePage=(page)=>{ diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js index a9c73fee6..5683c95df 100644 --- a/src/forge/Main/CoderRootDirectory.js +++ b/src/forge/Main/CoderRootDirectory.js @@ -10,7 +10,6 @@ import RootTable from './RootTable'; import CoderRootFileDetail from './CoderRootFileDetail'; import { truncateCommitId } from '../common/util'; import RenderHtml from '../../components/render-html'; -import Top from './DetailTop'; import axios from "axios"; /** @@ -44,9 +43,6 @@ class CoderRootDirectory extends Component { zip_url:undefined, tar_url:undefined, chooseType:undefined, - tags_count:undefined, - commits_count:undefined, - branches_count:undefined, md:false } @@ -125,10 +121,7 @@ class CoderRootDirectory extends Component { lastCommitAuthor: last_commit && (last_commit.author || (last_commit.commit && last_commit.commit.author)), zip_url: result.data.zip_url, - tar_url: result.data.tar_url, - tags_count: result.data.tags_count, - branches_count: result.data.branches_count, - commits_count: result.data.commits_count + tar_url: result.data.tar_url }); if (entries && entries.length > 0) { this.renderData(entries); @@ -321,6 +314,9 @@ class CoderRootDirectory extends Component { isSpin: true, readOnly:true }); + const { getTopCount } = this.props; + getTopCount && getTopCount(value); + let { search } = this.props.history.location; if (search && search.indexOf("?url=") > -1) { let url = search.split("?url=")[1]; @@ -456,7 +452,6 @@ class CoderRootDirectory extends Component { let array = filePath && filePath.split("/"); return ( -
diff --git a/src/forge/Main/CoderRootIndex.js b/src/forge/Main/CoderRootIndex.js index c3a17214f..3b3e7d28d 100644 --- a/src/forge/Main/CoderRootIndex.js +++ b/src/forge/Main/CoderRootIndex.js @@ -1,10 +1,18 @@ import React , { Component } from 'react'; import { Route , Switch } from 'react-router-dom'; - +import Top from './DetailTop'; import Loadable from 'react-loadable'; import Loading from '../../Loading'; +import axios from 'axios'; - +const FileNew = Loadable({ + loader: () => import('../Newfile/Index'), + loading: Loading, +}) +const UploadFile = Loadable({ + loader: () => import('../Newfile/upload_file'), + loading: Loading, +}) const CoderRootDirectory = Loadable({ loader: () => import('./CoderRootDirectory'), loading: Loading, @@ -39,56 +47,102 @@ const Diff = Loadable({ }) class CoderRootIndex extends Component{ + constructor(props){ + super(props); + this.state={ + coderCount:undefined + } + } + + componentDidMount=()=>{ + let { search } = this.props.history.location; + let branchName = undefined; + if (search && search.indexOf("?branch=") > -1) { + branchName = search.split("?branch=")[1]; + } + this.getTopCount(branchName); + } + + getTopCount=(branch)=>{ + const { projectsId } = this.props.match.params; + const url = `/repositories/${projectsId}/top_counts.json`; + axios.get(url,{params:{ + ref:branch + }}).then(result=>{ + if(result){ + this.setState({ + coderCount:result.data + }) + } + }).catch(error=>{console.log(error);}) + } render(){ return(
+ + {/* 新建文件 */} + () + } + > + () + } + > + () + } + > () + () => () } > {/* diff */} () + () => () } > () + () => () } > () + () => () } > () + () => () } > () + () => () } > () + () => () } > () + () => () } > () + () => () } > diff --git a/src/forge/Main/CoderRootTag.js b/src/forge/Main/CoderRootTag.js index 583d1d28d..e015310f4 100644 --- a/src/forge/Main/CoderRootTag.js +++ b/src/forge/Main/CoderRootTag.js @@ -35,7 +35,6 @@ export default ({
  • 标签名 - {/* 描述 */} 提交信息 下载
  • @@ -49,10 +48,8 @@ export default ({ {item.name} - {/* 坎坎坷坷死二无一额坎坎坷坷死二无一额坎坎坷坷死二无一额 */} {truncateCommitId(`${item.id}`)} - {/* 2020-05-18 16:30 */} TAR diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index dc1b1e7f2..c570893ac 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -21,14 +21,6 @@ import img_parised from '../Images/parised.png'; import img_focused from '../Images/focused.png'; import img_fork from '../Images/fork.png'; import img_milepost from '../Images/milepost.png'; -const FileNew = Loadable({ - loader: () => import('../Newfile/Index'), - loading: Loading, -}) -const UploadFile = Loadable({ - loader: () => import('../Newfile/upload_file'), - loading: Loading, -}) const Setting = Loadable({ loader: () => import('../Settings/Index'), loading: Loading, @@ -146,7 +138,7 @@ class Detail extends Component { branchList: undefined, project: null, firstSync:false, - secondSync:false + secondSync:false, } } @@ -314,7 +306,6 @@ class Detail extends Component { const url = `/repositories/${repo_id}/sync_mirror.json`; axios.post(url).then(result => { if (result && result.data && result.data.status === 0) { - // this.props.showNotification("镜像同步成功!"); this.getProject(2); } else { this.props.showNotification("镜像同步失败!"); @@ -345,12 +336,6 @@ class Detail extends Component { : "" ); - const mirror = ( - - 镜像自 - {projectDetail && projectDetail.mirror_url} - - ) const common = { getDetail: this.getDetail } @@ -477,23 +462,6 @@ class Detail extends Component { : - {/* 新建文件 */} - () - } - > - () - } - > - () - } - > - {/* 标签列表 */} 0 ? "active" : ""}> - {commits_count}个提交 + {(coderCount && coderCount.commits_count) || 0}个提交 0 ? "active" : ""}> - {branches_count}个分支 + {(coderCount && coderCount.branches_count) || 0}个分支 0 ? "active" : ""}> - {tags_count}个标签 + {(coderCount && coderCount.tags_count) || 0}个标签 0 ? "active" : ""}> - {projectDetail && projectDetail.version_releasesed_count}个发行版 + {(coderCount && coderCount.version_releasesed_count) || 0}个发行版 - {/* 0 ? "active" : ""}> - - {projectDetail && projectDetail.contributor_users_count}位贡献者 - */} - 仓库 {projectDetail && projectDetail.size} + 仓库 {(coderCount && coderCount.size) || 0}

    ) diff --git a/src/forge/Newfile/Index.js b/src/forge/Newfile/Index.js index a30161715..5f8ffd99a 100644 --- a/src/forge/Newfile/Index.js +++ b/src/forge/Newfile/Index.js @@ -1,6 +1,5 @@ import React, { Component } from "react"; import Meditor from "./m_editor"; -import Top from "../Main/DetailTop"; import "./index.css"; import { Input, Select } from "antd"; @@ -94,7 +93,6 @@ class Index extends Component { ]; return ( -

    新建文件 diff --git a/src/forge/Newfile/UserSubmitComponent.js b/src/forge/Newfile/UserSubmitComponent.js index 5ab142d23..1febfebfe 100644 --- a/src/forge/Newfile/UserSubmitComponent.js +++ b/src/forge/Newfile/UserSubmitComponent.js @@ -56,8 +56,8 @@ class UserSubmitComponent extends Component { this.props.history.push(url); this.props.showNotification("文件新建成功!"); if(submitType === "1"){ - const { getDetail } = this.props; - getDetail && getDetail(); + const { getTopCount } = this.props; + getTopCount && getTopCount(values.branchname); } } }) diff --git a/src/forge/Newfile/upload_file.js b/src/forge/Newfile/upload_file.js index 877c75fbf..2abf104ae 100644 --- a/src/forge/Newfile/upload_file.js +++ b/src/forge/Newfile/upload_file.js @@ -1,8 +1,5 @@ import React, { Component } from "react"; -// import Meditor from "./m_editor"; -import Top from "../Main/DetailTop"; import "./index.css"; -// import { Input, Select } from "antd"; import UserSubmitComponent from "./UserSubmitComponent"; import Upload from "../Upload/read"; import UploadImg from "../Images/upload.png"; @@ -34,7 +31,6 @@ class UploadFile extends Component { return ( -

    上传文件 diff --git a/src/forge/Order/New.js b/src/forge/Order/New.js index 13aaef1f1..d169cb636 100644 --- a/src/forge/Order/New.js +++ b/src/forge/Order/New.js @@ -1,10 +1,10 @@ import React, { Component } from "react"; -import OrderItem from './order_form' +import OrderForm from './order_form' class New extends Component { render() { return ( - + ) }