Merge pull request '细节问题以及去掉不必要的接口' (#133) from caishi/forgeplus-react:pre_develop_dev into pre_develop_dev

This commit is contained in:
jasder 2021-10-11 18:38:39 +08:00
commit 4e3215c6f9
3 changed files with 33 additions and 35 deletions

View File

@ -3,7 +3,6 @@ import { Route , Switch } from 'react-router-dom';
// import Top from './DetailTop'; // import Top from './DetailTop';
import Loadable from 'react-loadable'; import Loadable from 'react-loadable';
import Loading from '../../Loading'; import Loading from '../../Loading';
import axios from 'axios';
import './Index.scss'; import './Index.scss';
const FileNew = Loadable({ const FileNew = Loadable({
@ -51,37 +50,37 @@ class CoderRootIndex extends Component{
} }
} }
componentDidMount=()=>{ // componentDidMount=()=>{
this.Init(); // this.Init();
} // }
componentDidUpdate=(prevProps)=>{ // componentDidUpdate=(prevProps)=>{
const { location } = this.props; // const { location } = this.props;
const prevlocation = prevProps && prevProps.location; // const prevlocation = prevProps && prevProps.location;
if (location !== prevlocation) { // if (location !== prevlocation) {
this.Init(); // this.Init();
} // }
} // }
Init=()=>{ // Init=()=>{
const { branchName } = this.props.match.params; // const { branchName } = this.props.match.params;
const { defaultBranch } = this.props; // const { defaultBranch } = this.props;
this.getTopCount(branchName || defaultBranch); // this.getTopCount(branchName || defaultBranch);
} // }
// 获取<Top />组件里要显示的数据 // 获取<Top />组件里要显示的数据
getTopCount=(branch)=>{ // getTopCount=(branch)=>{
const { projectsId , owner } = this.props.match.params; // const { projectsId , owner } = this.props.match.params;
const url = `/${owner}/${projectsId}/top_counts.json`; // const url = `/${owner}/${projectsId}/top_counts.json`;
axios.get(url,{params:{ // axios.get(url,{params:{
ref:branch // ref:branch
}}).then(result=>{ // }}).then(result=>{
if(result){ // if(result){
this.setState({ // this.setState({
coderCount:result.data // coderCount:result.data
}) // })
} // }
}).catch(error=>{console.log(error);}) // }).catch(error=>{console.log(error);})
} // }
render(){ render(){
return( return(
<div className="coderSubPage"> <div className="coderSubPage">
@ -100,12 +99,12 @@ class CoderRootIndex extends Component{
></Route> ></Route>
<Route path="/:owner/:projectsId/:branch/newfile" <Route path="/:owner/:projectsId/:branch/newfile"
render={ render={
(props) => (<FileNew {...this.props} {...props} {...this.state} getTopCount={this.getTopCount} />) (props) => (<FileNew {...this.props} {...props} {...this.state} />)
} }
></Route> ></Route>
<Route path="/:owner/:projectsId/commits/branch/:branchName" <Route path="/:owner/:projectsId/commits/branch/:branchName"
render={ render={
() => (<CoderRootCommit {...this.props} {...this.state} commit_class="main" getTopCount={this.getTopCount} />) () => (<CoderRootCommit {...this.props} {...this.state} commit_class="main" />)
} }
></Route> ></Route>
<Route path="/:owner/:projectsId/commits/:sha" <Route path="/:owner/:projectsId/commits/:sha"
@ -115,7 +114,7 @@ class CoderRootIndex extends Component{
></Route> ></Route>
<Route path="/:owner/:projectsId/commits" <Route path="/:owner/:projectsId/commits"
render={ render={
() => (<CoderRootCommit {...this.props} {...this.state} commit_class="main" getTopCount={this.getTopCount} />) () => (<CoderRootCommit {...this.props} {...this.state} commit_class="main" />)
} }
></Route> ></Route>
{/* <Route path="/:owner/:projectsId/releases/:versionId/update" {/* <Route path="/:owner/:projectsId/releases/:versionId/update"

View File

@ -224,7 +224,7 @@
height: 8px; height: 8px;
width: 8px; width: 8px;
left: 0px; left: 0px;
top:10px top:8px;
} }
&>span{ &>span{
padding-left: 15px; padding-left: 15px;

View File

@ -83,8 +83,7 @@ class UserSubmitComponent extends Component {
if (result.data && result.data.name) { if (result.data && result.data.name) {
this.props.showNotification("文件新建成功!"); this.props.showNotification("文件新建成功!");
if(submitType === "1"){ if(submitType === "1"){
const { getTopCount , getDetail } = this.props; const { getDetail } = this.props;
getTopCount && getTopCount(values.branchname);
getDetail && getDetail(); getDetail && getDetail();
} }
let url = `/${owner}/${projectsId}${values.branchname ? `/tree/${turnbar(values.branchname)}`: (branch ? `/tree/${turnbar(branch)}` : "")}`; let url = `/${owner}/${projectsId}${values.branchname ? `/tree/${turnbar(values.branchname)}`: (branch ? `/tree/${turnbar(branch)}` : "")}`;