This commit is contained in:
caishi 2021-03-02 11:40:55 +08:00
parent 80f1e4d448
commit 72fcbcd4dd
3 changed files with 8 additions and 7 deletions

View File

@ -92,8 +92,8 @@ class CoderRootDirectory extends Component {
const { branchName , owner , projectsId } = this.props.match.params;
const { defaultBranch } = this.props;
let branch = branchName || defaultBranch;
if (pathname && (pathname.indexOf(`/projects/${owner}/${projectsId}`) > -1 && pathname.indexOf("/tree/") > -1)) {
let url = pathname.split("/tree/")[1];
if (pathname && (pathname.indexOf(`/projects/${owner}/${projectsId}`) > -1 && pathname.indexOf(`/tree/${branchName}/`) > -1)) {
let url = pathname.split(`/tree/${branchName}/`)[1];
this.setState({treeValue:url})
this.getFileDetail(decodeURI(url),branch);
} else {
@ -108,7 +108,7 @@ class CoderRootDirectory extends Component {
readOnly:true,
treeValue:undefined
})
this.props.history.push(`/projects/${owner}/${projectsId}${branchName?`/branch/${branchName}`:""}`);
this.props.history.push(`/projects/${owner}/${projectsId}${branchName?`/tree/${branchName}`:""}`);
this.getProjectRoot(branch);
};
@ -235,7 +235,8 @@ class CoderRootDirectory extends Component {
chooseType:type
})
const { projectsId, owner , branchName } = this.props.match.params;
this.props.history.push(`/projects/${owner}/${projectsId}${branchName?`/branch/${branchName}`:""}${path?`/tree/${path}`:""}`);
const { defaultBranch } = this.props;
this.props.history.push(`/projects/${owner}/${projectsId}${`/tree/${branchName || defaultBranch}`}${path?`/${path}`:""}`);
if(filename.substring(filename.length - 3) === ".md"){
this.setState({
md:true
@ -290,7 +291,7 @@ class CoderRootDirectory extends Component {
changeBranch = (value) => {
const { projectsId , owner } = this.props.match.params;
const { treeValue } = this.state;
let url = `/projects/${owner}/${projectsId}${value && `/branch/${value}`}${treeValue ? `/tree/${treeValue}`:""}`;
let url = `/projects/${owner}/${projectsId}${value && `/tree/${value}`}${treeValue ? `/${treeValue}`:""}`;
this.props.history.push(url);
}

View File

@ -145,7 +145,7 @@ class CoderRootIndex extends Component{
() => (<CoderRootTag {...this.props} {...this.state} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/branch/:branchName"
<Route path="/projects/:owner/:projectsId/tree/:branchName"
render={
(props) => (<CoderRootDirectory {...this.props} {...this.state} getTopCount={this.getTopCount} />)
}

View File

@ -701,7 +701,7 @@ class Detail extends Component {
(props) => (<CoderRootIndex {...this.props} {...props} {...this.state} {...common} />)
}
></Route>
<Route path="/projects/:owner/:projectsId/branch/:branchName"
<Route path="/projects/:owner/:projectsId/tree/:branchName"
render={
(props) => (<CoderRootIndex {...this.props} {...props} {...this.state} {...common} />)
}