From 9452296dea7e63bfb13f7ae94126ccf733f763f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com> Date: Thu, 20 Jul 2023 10:35:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=B3=E4=BE=A7=E5=AF=BC?= =?UTF-8?q?=E8=88=AA=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Information/Pages/help.jsx | 29 +++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/forge/Information/Pages/help.jsx b/src/forge/Information/Pages/help.jsx index f456ebea..bbcad47e 100644 --- a/src/forge/Information/Pages/help.jsx +++ b/src/forge/Information/Pages/help.jsx @@ -23,7 +23,6 @@ function ProjectSource(props) { const [autoExpandParent, setAutoExpandParent] = useState(false); const [searchValue, setSearchValue] = useState(""); const [wikiContMenu, setWikiContMenu] = useState(undefined); - const [container, setContainer] = useState(undefined); const { temp, history, data, adminUrl } = props; let scroller = undefined; @@ -112,6 +111,7 @@ function ProjectSource(props) { }, [wikiDetail]) useEffect(() =>{ + // 点击事件 const handleClick = (event) => { let target = event.target; if (target.tagName.toUpperCase() === 'A') { @@ -127,9 +127,29 @@ function ProjectSource(props) { } } }; + + // 滚动 + const scroll = () =>{ + var element = document.getElementById('wikiContMenuBox'); + var scrollTop = document.documentElement.scrollTop||document.body.scrollTop; + var windowHeight = document.documentElement.clientHeight || document.body.clientHeight; + var scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight; + if(scrollHeight-scrollTop <= windowHeight*1.2){ + const maxElementHeight = (scrollHeight-scrollTop)/2-200; + element && (element.style.maxHeight = maxElementHeight + 'px'); + }else if(scrollHeight-scrollTop <= windowHeight*1.5){ + const maxElementHeight = (scrollHeight-scrollTop)/2-100; + element && (element.style.maxHeight = maxElementHeight + 'px'); + }else{ + element && (element.style.maxHeight = '80vh'); + } + } + document.addEventListener("click", handleClick); + document.addEventListener("scroll", scroll); return () => { document.removeEventListener("click", handleClick); + document.removeEventListener("scroll", scroll); }; }, []) @@ -191,7 +211,7 @@ function ProjectSource(props) {

{data && data.helperTitle}

{ - wikiList && (wikiList.length > 0 ? {setContainer(node)}}> + wikiList && (wikiList.length > 0 ? {/* wiki目录导航 */}
{wikiDetail.md_content && } - {/* target={() => container} */} - {wikiContMenu && wikiContMenu !== "
    " && -
    + {wikiContMenu && wikiContMenu !== "
      " && +
      } }