This commit is contained in:
caishi 2020-08-27 10:14:07 +08:00
parent 74d26a40d3
commit 33c3395221
1 changed files with 20 additions and 11 deletions

View File

@ -20,6 +20,16 @@ import axios from "axios";
* readMeContent:根目录下面的readme文件内容 * readMeContent:根目录下面的readme文件内容
*/ */
function getPathUrl(array,index){
if(array && array.length>0 && index){
let str = "";
for(let i=0;i<index;i++){
str += `/${array[i]}`;
}
return str.substr(1);
}
}
class CoderRootDirectory extends Component { class CoderRootDirectory extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -95,7 +105,7 @@ class CoderRootDirectory extends Component {
this.setState({ this.setState({
readOnly:true readOnly:true
}) })
this.props.history.push(`/projects/${owner}/${projectsId}`); this.props.history.push(`/projects/${owner}/${projectsId}/coders`);
this.getProjectRoot(branch); this.getProjectRoot(branch);
}; };
@ -132,7 +142,7 @@ class CoderRootDirectory extends Component {
ChangeFile = (arr, readOnly) => { ChangeFile = (arr, readOnly) => {
const { projectsId , owner } = this.props.match.params; const { projectsId , owner } = this.props.match.params;
//点击直接跳转页面 加载一次路由 //点击直接跳转页面 加载一次路由
this.props.history.push(`/projects/${owner}/${projectsId}?url=${arr.path}`); this.props.history.push(`/projects/${owner}/${projectsId}/coders?url=${arr.path}`);
this.setState({ this.setState({
readOnly: readOnly, readOnly: readOnly,
chooseType:"file" chooseType:"file"
@ -163,7 +173,7 @@ class CoderRootDirectory extends Component {
const { projectsId , owner } = this.props.match.params; const { projectsId , owner } = this.props.match.params;
//点击直接跳转页面 加载一次路由 //点击直接跳转页面 加载一次路由
this.props.history.push( this.props.history.push(
`/projects/${owner}/${projectsId}?url=${str.substr(1)}` `/projects/${owner}/${projectsId}/coders?url=${str.substr(1)}`
); );
} else { } else {
list.push({ list.push({
@ -247,7 +257,7 @@ class CoderRootDirectory extends Component {
chooseType:type chooseType:type
}) })
const { projectsId, owner } = this.props.match.params; const { projectsId, owner } = this.props.match.params;
this.props.history.push(`/projects/${owner}/${projectsId}?url=${path}`); this.props.history.push(`/projects/${owner}/${projectsId}/coders?url=${path}`);
if(filename.substring(filename.length - 3) === ".md"){ if(filename.substring(filename.length - 3) === ".md"){
this.setState({ this.setState({
md:true md:true
@ -330,7 +340,7 @@ class CoderRootDirectory extends Component {
readOnly:true readOnly:true
}) })
const { projectsId , owner } = this.props.match.params; const { projectsId , owner } = this.props.match.params;
this.props.history.push(`/projects/${owner}/${projectsId}?url=${url}`); this.props.history.push(`/projects/${owner}/${projectsId}/coders?url=${url}`);
} }
onEdit=(readOnly)=>{ onEdit=(readOnly)=>{
@ -357,7 +367,6 @@ class CoderRootDirectory extends Component {
} }
title = (branchLastCommit,lastCommitAuthor) => { title = (branchLastCommit,lastCommitAuthor) => {
console.log(branchLastCommit)
if (branchLastCommit) { if (branchLastCommit) {
return ( return (
<div className="f-wrap-alignCenter"> <div className="f-wrap-alignCenter">
@ -398,6 +407,7 @@ class CoderRootDirectory extends Component {
} }
} }
render(){ render(){
const { branchLastCommit , lastCommitAuthor , rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin , zip_url , tar_url} = this.state; const { branchLastCommit , lastCommitAuthor , rootList , branch ,filePath , fileDetail , subFileType , readMeContent, isSpin , zip_url , tar_url} = this.state;
const { isManager , isDeveloper , projectDetail } = this.props; const { isManager , isDeveloper , projectDetail } = this.props;
@ -458,15 +468,14 @@ class CoderRootDirectory extends Component {
> >
{projectDetail && projectDetail.identifier} {projectDetail && projectDetail.identifier}
</a> </a>
{array && { array && array.map((item, key) => {
array.map((item, key) => {
return ( return (
<React.Fragment> <React.Fragment>
{ {
key === array.length-1 ? key === array.length-1 ?
<span className="color-grey-6 subFileName" key={key}>{item}</span> <span className="color-grey-6 subFileName" key={key}>{item}</span>
: :
<a onClick={()=>this.returnUlr(`${key === 0 ? `${item}` :`${array[key-1]}/${item}`}`)} className="color-blue subFileName">{item}</a> <a onClick={()=>this.returnUlr(`${getPathUrl(array,key+1)}`)} className="color-blue subFileName">{item}</a>
} }
</React.Fragment> </React.Fragment>
); );
@ -478,13 +487,13 @@ class CoderRootDirectory extends Component {
{subFileType && (projectDetail && parseInt(projectDetail.type)) !== 2 && (isManager || isDeveloper) && ( {subFileType && (projectDetail && parseInt(projectDetail.type)) !== 2 && (isManager || isDeveloper) && (
<div> <div>
<span> <span>
<Link to={`/projects/${owner}/${projectsId}/${branch}/uploadfile${urlRoot}`} > <Link to={`/projects/${owner}/${projectsId}/coders/${branch}/uploadfile${urlRoot}`} >
<span className="color-green mr30">上传文件</span> <span className="color-green mr30">上传文件</span>
</Link> </Link>
</span> </span>
<span className="mr30"> <span className="mr30">
<Link <Link
to={`/projects/${owner}/${projectsId}/${branch}/newfile${urlRoot}`} to={`/projects/${owner}/${projectsId}/coders/${branch}/newfile${urlRoot}`}
> >
<span className="color-blue">新建文件</span> <span className="color-blue">新建文件</span>
</Link> </Link>