From a9d1fea75d3386eb49561b02dbd5b16f30214b14 Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Fri, 3 Jan 2020 16:22:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E6=94=AF=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- .../src/forge/Main/CoderRootDirectory.js | 78 ++++++++++--------- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7bc741cf6..9312fce1c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -328,7 +328,7 @@ class ApplicationController < ActionController::Base def current_user # User.current - User.find_by_id 1 + User.find_by_id 50207 end ## 默认输出json 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 = (