This commit is contained in:
caishi 2020-11-06 22:35:28 +08:00
parent 2e04851b66
commit 0dd722d898
1 changed files with 10 additions and 7 deletions

View File

@ -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,