From 72fcbcd4dd792a91ef183c0ba53d4f12e5513211 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Tue, 2 Mar 2021 11:40:55 +0800 Subject: [PATCH] root --- src/forge/Main/CoderRootDirectory.js | 11 ++++++----- src/forge/Main/CoderRootIndex.js | 2 +- src/forge/Main/Detail.js | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js index a6dc2658..759165de 100644 --- a/src/forge/Main/CoderRootDirectory.js +++ b/src/forge/Main/CoderRootDirectory.js @@ -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); } diff --git a/src/forge/Main/CoderRootIndex.js b/src/forge/Main/CoderRootIndex.js index 27dbbb9d..0e9c7207 100644 --- a/src/forge/Main/CoderRootIndex.js +++ b/src/forge/Main/CoderRootIndex.js @@ -145,7 +145,7 @@ class CoderRootIndex extends Component{ () => () } > - () } diff --git a/src/forge/Main/Detail.js b/src/forge/Main/Detail.js index 76852525..00d80046 100644 --- a/src/forge/Main/Detail.js +++ b/src/forge/Main/Detail.js @@ -701,7 +701,7 @@ class Detail extends Component { (props) => () } > - () }