From 0dd722d898b7be274818b32ed3b1f4eebae16e80 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 6 Nov 2020 22:35:28 +0800 Subject: [PATCH] router --- src/forge/Main/CoderRootDirectory.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/forge/Main/CoderRootDirectory.js b/src/forge/Main/CoderRootDirectory.js index 3a18682a..12dbf73b 100644 --- a/src/forge/Main/CoderRootDirectory.js +++ b/src/forge/Main/CoderRootDirectory.js @@ -89,17 +89,18 @@ class CoderRootDirectory extends Component { this.setState({ branch: branchName, }); + }else{ + branchName = undefined; + this.setState({ + branch: "master", + }); } if (search && (search.indexOf("?url=") > -1 || search.indexOf("&url=") > -1)) { let url = search.split("url=")[1]; - if(url && decodeURI(url).indexOf("&")){ url=decodeURI(url).split("&")[0]; } - this.setState({ - filePath: decodeURI(url), - }); - this.getFileDetail(decodeURI(url)); + this.getFileDetail(decodeURI(url),branchName); } else { const { branch } = this.state; this.getProjectRoot(branchName || branch); @@ -190,10 +191,12 @@ class CoderRootDirectory extends Component { // 获取子目录 getFileDetail = (path, ref) => { + this.setState({ + filePath: decodeURI(path), + }); const { projectsId ,owner } = this.props.match.params; const { branch , chooseType } = this.state; const url = `/${owner}/${projectsId}/sub_entries.json`; - axios.get(url,{ params:{ filepath:path, @@ -209,7 +212,7 @@ class CoderRootDirectory extends Component { if( entries && entries.length > 0){ let { chooseType } = this.state; // 当前返回的子目录只有一条数据,且这条数据返回的是文件类型 - if(entries.length === 1 && entries[0].type === "file" && chooseType ==="file"){ + if(entries.length === 1 && (entries[0].type === "file" || chooseType ==="file")){ this.setState({ fileDetail:entries, rootList:undefined,