切换分支

This commit is contained in:
caicai8 2020-04-23 14:11:43 +08:00
parent 38709b1cab
commit 0502fb1317
1 changed files with 12 additions and 4 deletions

View File

@ -163,7 +163,7 @@ class CoderRootDirectory extends Component{
} }
// 获取子目录 // 获取子目录
getFileDetail=(path)=>{ getFileDetail=(path,ref)=>{
const { projectsId } = this.props.match.params; const { projectsId } = this.props.match.params;
const { branch } = this.state; const { branch } = this.state;
const url =`/repositories/${projectsId}/sub_entries.json`; const url =`/repositories/${projectsId}/sub_entries.json`;
@ -171,7 +171,7 @@ class CoderRootDirectory extends Component{
axios.get(url,{ axios.get(url,{
params:{ params:{
filepath:path, filepath:path,
ref:branch ref:ref || branch
} }
}).then((result)=>{ }).then((result)=>{
if(result && result.data && result.data.length > 0){ if(result && result.data && result.data.length > 0){
@ -263,8 +263,16 @@ class CoderRootDirectory extends Component{
http_url:branchLastCommit && branchLastCommit.http_url, http_url:branchLastCommit && branchLastCommit.http_url,
isSpin: true isSpin: true
}) })
this.Init(); const { pathname } = this.props.location;
if(pathname && pathname.indexOf("/filesurl/")>-1){
let url =pathname.split("filesurl/")[1];
this.setState({
filePath:url
})
this.getFileDetail(url,branchLastCommit && branchLastCommit.name);
}else{
this.getProjectRoot( branchLastCommit && branchLastCommit.name );
}
} }
render(){ render(){
const { rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin } = this.state; const { rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin } = this.state;