|
|
@ -1,6 +1,6 @@
|
|
|
|
import React , { Component } from 'react';
|
|
|
|
import React , { Component } from 'react';
|
|
|
|
import { Menu } from 'antd';
|
|
|
|
import { Menu } from 'antd';
|
|
|
|
import { getImageUrl } from 'educoder';
|
|
|
|
import { getImageUrl , markdownToHTML } from 'educoder';
|
|
|
|
import { Router , Route , Link } from 'react-router-dom';
|
|
|
|
import { Router , Route , Link } from 'react-router-dom';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -17,6 +17,8 @@ import axios from 'axios';
|
|
|
|
* branch:当前分支
|
|
|
|
* branch:当前分支
|
|
|
|
* filePath:点击目录时当前目录的路径
|
|
|
|
* filePath:点击目录时当前目录的路径
|
|
|
|
* subfileType:保存当前点击目录的文件类型(显示目录列表时才显示新建文件,如果点击的是文件就不显示新建文件按钮)
|
|
|
|
* subfileType:保存当前点击目录的文件类型(显示目录列表时才显示新建文件,如果点击的是文件就不显示新建文件按钮)
|
|
|
|
|
|
|
|
* readMeContent:根目录下面的readme文件内容
|
|
|
|
|
|
|
|
* current_path:当前文件路径
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class CoderRootDirectory extends Component{
|
|
|
|
class CoderRootDirectory extends Component{
|
|
|
|
constructor(props){
|
|
|
|
constructor(props){
|
|
|
@ -27,6 +29,8 @@ class CoderRootDirectory extends Component{
|
|
|
|
filePath:[],
|
|
|
|
filePath:[],
|
|
|
|
http_url:undefined,
|
|
|
|
http_url:undefined,
|
|
|
|
subFileType:"",
|
|
|
|
subFileType:"",
|
|
|
|
|
|
|
|
readMeContent:undefined,
|
|
|
|
|
|
|
|
current_path:undefined,
|
|
|
|
|
|
|
|
|
|
|
|
branchList:undefined,
|
|
|
|
branchList:undefined,
|
|
|
|
fileDetail:undefined,
|
|
|
|
fileDetail:undefined,
|
|
|
@ -68,7 +72,8 @@ class CoderRootDirectory extends Component{
|
|
|
|
this.renderUrl(arr.name,arr.path,arr.type);
|
|
|
|
this.renderUrl(arr.name,arr.path,arr.type);
|
|
|
|
this.getFileDetail(arr);
|
|
|
|
this.getFileDetail(arr);
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
subFileType:arr.type
|
|
|
|
subFileType:arr.type,
|
|
|
|
|
|
|
|
current_path:arr.path
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -133,17 +138,43 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
|
|
|
|
|
|
|
renderData=(data)=>{
|
|
|
|
renderData=(data)=>{
|
|
|
|
const rootList = [];
|
|
|
|
const rootList = [];
|
|
|
|
|
|
|
|
const readMeContent = [];
|
|
|
|
data && data.map((item,key)=>{
|
|
|
|
data && data.map((item,key)=>{
|
|
|
|
rootList.push({
|
|
|
|
rootList.push({
|
|
|
|
key,
|
|
|
|
key,
|
|
|
|
...item
|
|
|
|
...item
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
if(item.name === 'README.md'){
|
|
|
|
|
|
|
|
readMeContent.push({...item})
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
rootList:rootList
|
|
|
|
rootList:rootList,
|
|
|
|
|
|
|
|
readMeContent
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// readme文件内容
|
|
|
|
|
|
|
|
renderReadMeContent=(readMeContent)=>{
|
|
|
|
|
|
|
|
const { fileDetail } = this.state;
|
|
|
|
|
|
|
|
if(fileDetail){return;}
|
|
|
|
|
|
|
|
if(readMeContent && readMeContent.length > 0){
|
|
|
|
|
|
|
|
return(
|
|
|
|
|
|
|
|
<div className="commonBox">
|
|
|
|
|
|
|
|
<div className="commonBox-title">{readMeContent[0].name}</div>
|
|
|
|
|
|
|
|
<div className="commonBox-info">
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
readMeContent[0].content ?
|
|
|
|
|
|
|
|
<div className={"markdown-body"} dangerouslySetInnerHTML={{__html: markdownToHTML(readMeContent[0].content).replace(/▁/g, "▁▁▁")}}></div>
|
|
|
|
|
|
|
|
:
|
|
|
|
|
|
|
|
<span>暂无~</span>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 选择分支
|
|
|
|
// 选择分支
|
|
|
|
changeBranch=(value)=>{
|
|
|
|
changeBranch=(value)=>{
|
|
|
|
const { branchList } = this.props;
|
|
|
|
const { branchList } = this.props;
|
|
|
@ -158,7 +189,7 @@ class CoderRootDirectory extends Component{
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
render(){
|
|
|
|
render(){
|
|
|
|
const { rootList , branch ,filePath , fileDetail , subFileType } = this.state;
|
|
|
|
const { rootList , branch ,filePath , fileDetail , subFileType , readMeContent , current_path } = this.state;
|
|
|
|
|
|
|
|
|
|
|
|
const { branchLastCommit , http_url , isManager , isDeveloper } = this.props;
|
|
|
|
const { branchLastCommit , http_url , isManager , isDeveloper } = this.props;
|
|
|
|
const { projectsId } = this.props.match.params;
|
|
|
|
const { projectsId } = this.props.match.params;
|
|
|
@ -256,9 +287,12 @@ class CoderRootDirectory extends Component{
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fileDetail &&
|
|
|
|
fileDetail &&
|
|
|
|
<CoderRootFileDetail detail = {fileDetail}></CoderRootFileDetail>
|
|
|
|
<CoderRootFileDetail detail = {fileDetail} current_path={current_path} {...this.props} {...this.state}></CoderRootFileDetail>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{/* readme.txt */}
|
|
|
|
|
|
|
|
{ this.renderReadMeContent(readMeContent) }
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|