diff --git a/public/react/src/forge/Main/CoderRootDirectory.js b/public/react/src/forge/Main/CoderRootDirectory.js index a2ff94b40..6ae882015 100644 --- a/public/react/src/forge/Main/CoderRootDirectory.js +++ b/public/react/src/forge/Main/CoderRootDirectory.js @@ -14,7 +14,9 @@ class CoderRootDirectory extends Component{ super(props); this.state={ address:"http", - ref:"master" + ref:"master", + + rootList:undefined } } @@ -26,8 +28,23 @@ class CoderRootDirectory extends Component{ componentDidMount=()=>{ this.getProjectRoot(); + this.getBranch(); + } + + // 获取分支列表 + getBranch=()=>{ + const { login } = this.props.current_user; + const { projectsId } = this.props.match.params; + + const url =`/projects/${login}/${projectsId}/branches.json`; + axios.get(url).then((result)=>{ + if(result){ + + } + }).catch((error)=>{}) } + // 获取分支文件 getProjectRoot=(ref)=>{ const { login } = this.props.current_user; const { projectsId } = this.props.match.params; @@ -38,12 +55,25 @@ class CoderRootDirectory extends Component{ ref } }).then((result)=>{ - if(result){ - + if(result && result.data && result.data.length > 0){ + this.renderData(result.data) } }).catch((error)=>{}) } + renderData=(data)=>{ + const rootList = []; + data && data.map((item,key)=>{ + rootList.push({ + key, + ...item + }) + }) + this.setState({ + rootList:rootList + }) + } + render(){ const menu = (