From 45e69cb14a373dfe3ba54f7805cfd448c1b04ac3 Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Fri, 19 Mar 2021 16:29:43 +0800 Subject: [PATCH] update --- src/forge/Component/DrawerPanel.jsx | 9 +++++++-- src/forge/Main/CoderDepot.jsx | 13 ++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/forge/Component/DrawerPanel.jsx b/src/forge/Component/DrawerPanel.jsx index 167b0cd3..8070f3fa 100644 --- a/src/forge/Component/DrawerPanel.jsx +++ b/src/forge/Component/DrawerPanel.jsx @@ -4,13 +4,18 @@ import './Component.scss'; import axios from 'axios'; 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 [ isSpin , setIsSpin ] = useState(true); const [first , setFirst ] = useState(true); useEffect(()=>{ if(visible && first){ - getMenulist(); + if(list){ + setTreeData(list); + setIsSpin(false); + }else{ + getMenulist(); + } setFirst(false); } },[visible]) diff --git a/src/forge/Main/CoderDepot.jsx b/src/forge/Main/CoderDepot.jsx index b229fad5..932b9d22 100644 --- a/src/forge/Main/CoderDepot.jsx +++ b/src/forge/Main/CoderDepot.jsx @@ -36,6 +36,7 @@ function CoderDepot(props){ const [ readOnly , setReadOnly] = useState(true); const [ isSpin , setIsSpin] = useState(true); const [ visible ,setVisible ] = useState(false); + const [ mainFlag ,setMainFlag ] = useState(false); const owner = props.match.params.owner; const projectsId = props.match.params.projectsId; @@ -85,6 +86,7 @@ function CoderDepot(props){ let c = result.data.last_commit setLastCommit(c && c.commit); setLastCommitAuthor(c && (c.author || (c.commit && c.commit.author))); + setMainFlag(true); } setTimeout(function(){setIsSpin(false);},500); }).catch(error=>{setIsSpin(false);}) @@ -125,6 +127,7 @@ function CoderDepot(props){ let c = result.data.last_commit setLastCommit(c && c.commit); setLastCommitAuthor(c && (c.author || (c.commit && c.commit.author))); + setMainFlag(false); } setTimeout(function(){setIsSpin(false);},500) }).catch(error=>{setIsSpin(false);}) @@ -193,7 +196,7 @@ function CoderDepot(props){ { - dirInfo && + (dirInfo || fileInfo) && setVisible(false)} + list = {mainFlag ? dirInfo : undefined} />
setVisible(true)}>
@@ -264,7 +268,7 @@ function CoderDepot(props){ { hideBtn && changeHide(hide)}> } {lastCommit && lastCommit.time_from_now} - { commitCount ? {commitCount}次提交:"" } + { commitCount ? {commitCount}次提交:"" } } - : + : "" } + { + (dirInfo && dirInfo.length === 0) && (fileInfo && fileInfo.length === 0) ? :"" + } {/* readme文件显示(显示文件详情时不显示readme文件) */} { dirInfo && }