Merge branch 'develop_new' into develop_educoder

This commit is contained in:
caishi 2021-03-19 16:31:51 +08:00
commit 917958c880
2 changed files with 17 additions and 5 deletions

View File

@ -4,13 +4,18 @@ import './Component.scss';
import axios from 'axios'; import axios from 'axios';
const { TreeNode , DirectoryTree } = Tree; const { TreeNode , DirectoryTree } = Tree;
function DrawerPanel({visible,onClose,branch,owner,projectsId,history, name}){ function DrawerPanel({visible,onClose,branch,owner,projectsId,history, name , list}){
const [ treeData , setTreeData ] = useState(undefined); const [ treeData , setTreeData ] = useState(undefined);
const [ isSpin , setIsSpin ] = useState(true); const [ isSpin , setIsSpin ] = useState(true);
const [first , setFirst ] = useState(true); const [first , setFirst ] = useState(true);
useEffect(()=>{ useEffect(()=>{
if(visible && first){ if(visible && first){
getMenulist(); if(list){
setTreeData(list);
setIsSpin(false);
}else{
getMenulist();
}
setFirst(false); setFirst(false);
} }
},[visible]) },[visible])

View File

@ -36,6 +36,7 @@ function CoderDepot(props){
const [ readOnly , setReadOnly] = useState(true); const [ readOnly , setReadOnly] = useState(true);
const [ isSpin , setIsSpin] = useState(true); const [ isSpin , setIsSpin] = useState(true);
const [ visible ,setVisible ] = useState(false); const [ visible ,setVisible ] = useState(false);
const [ mainFlag ,setMainFlag ] = useState(false);
const owner = props.match.params.owner; const owner = props.match.params.owner;
const projectsId = props.match.params.projectsId; const projectsId = props.match.params.projectsId;
@ -85,6 +86,7 @@ function CoderDepot(props){
let c = result.data.last_commit let c = result.data.last_commit
setLastCommit(c && c.commit); setLastCommit(c && c.commit);
setLastCommitAuthor(c && (c.author || (c.commit && c.commit.author))); setLastCommitAuthor(c && (c.author || (c.commit && c.commit.author)));
setMainFlag(true);
} }
setTimeout(function(){setIsSpin(false);},500); setTimeout(function(){setIsSpin(false);},500);
}).catch(error=>{setIsSpin(false);}) }).catch(error=>{setIsSpin(false);})
@ -125,6 +127,7 @@ function CoderDepot(props){
let c = result.data.last_commit let c = result.data.last_commit
setLastCommit(c && c.commit); setLastCommit(c && c.commit);
setLastCommitAuthor(c && (c.author || (c.commit && c.commit.author))); setLastCommitAuthor(c && (c.author || (c.commit && c.commit.author)));
setMainFlag(false);
} }
setTimeout(function(){setIsSpin(false);},500) setTimeout(function(){setIsSpin(false);},500)
}).catch(error=>{setIsSpin(false);}) }).catch(error=>{setIsSpin(false);})
@ -193,7 +196,7 @@ function CoderDepot(props){
<WhiteBack> <WhiteBack>
<Spin spinning={isSpin}> <Spin spinning={isSpin}>
{ {
dirInfo && (dirInfo || fileInfo) &&
<React.Fragment> <React.Fragment>
<DrawerPanel <DrawerPanel
history={props.history} history={props.history}
@ -203,6 +206,7 @@ function CoderDepot(props){
branch={branchName || (projectDetail && projectDetail.default_branch)} branch={branchName || (projectDetail && projectDetail.default_branch)}
visible={visible} visible={visible}
onClose={()=>setVisible(false)} onClose={()=>setVisible(false)}
list = {mainFlag ? dirInfo : undefined}
/> />
<div className="drawerBtn" onClick={()=>setVisible(true)}><i className="iconfont icon-youjiantou"></i></div> <div className="drawerBtn" onClick={()=>setVisible(true)}><i className="iconfont icon-youjiantou"></i></div>
</React.Fragment> </React.Fragment>
@ -264,7 +268,7 @@ function CoderDepot(props){
{ hideBtn && <span className="ellipsis" onClick={()=>changeHide(hide)}><i className="iconfont icon-shenglvehao"></i></span> } { hideBtn && <span className="ellipsis" onClick={()=>changeHide(hide)}><i className="iconfont icon-shenglvehao"></i></span> }
<span className="ml12 color-grey-9 mt3">{lastCommit && lastCommit.time_from_now}</span> <span className="ml12 color-grey-9 mt3">{lastCommit && lastCommit.time_from_now}</span>
{ commitCount ? <span className="ml12 color-grey-9"><i className="iconfont icon-tijiao mr3 font-17 color-grey-9"></i>{commitCount}次提交</span>:"" } { commitCount ? <Link to={`/projects/${owner}/${projectsId}/commits`} className="ml12 color-grey-9"><i className="iconfont icon-tijiao mr3 font-17 color-grey-9"></i>{commitCount}次提交</Link>:"" }
</div> </div>
} }
<ul className="listtablebody"> <ul className="listtablebody">
@ -303,8 +307,11 @@ function CoderDepot(props){
} }
</ul> </ul>
</div> </div>
: <Nodata _html="暂未发现文件"/> : ""
} }
{
(dirInfo && dirInfo.length === 0) && (fileInfo && fileInfo.length === 0) ? <Nodata _html="暂未发现文件"/> :""
}
{/* readme文件显示(显示文件详情时不显示readme文件) */} {/* readme文件显示(显示文件详情时不显示readme文件) */}
{ dirInfo && <ReadMe ChangeFile={ChangeFile} readme={projectDetail && projectDetail.readme} operate={props && (props.isManager || props.isDeveloper)} history={props.history} /> } { dirInfo && <ReadMe ChangeFile={ChangeFile} readme={projectDetail && projectDetail.readme} operate={props && (props.isManager || props.isDeveloper)} history={props.history} /> }
</div> </div>