diff --git a/src/forge/Main/projecthome/v2/components/banner.jsx b/src/forge/Main/projecthome/v2/components/banner.jsx index 5ee47f12a..a3dd59720 100644 --- a/src/forge/Main/projecthome/v2/components/banner.jsx +++ b/src/forge/Main/projecthome/v2/components/banner.jsx @@ -9,6 +9,7 @@ import './index.scss'; function Banner({isVisible}) { const [active, setActive] = useState(0); const [active1, setActive1] = useState(0); + const [intervalId, setIntervalId] = useState(null); const lines1 = [ 'if(!isVisible)', @@ -77,6 +78,7 @@ function Banner({isVisible}) { }); }, 400); }, 3000); + setIntervalId(interval); // 清理定时器 return () => { @@ -84,6 +86,29 @@ function Banner({isVisible}) { }; }, []); + const pauseInterval = () => { + if (intervalId) { + clearInterval(intervalId); + setIntervalId(null); + } + }; + + const resumeInterval = () => { + if (!intervalId) { + const interval = setInterval(() => { + setActive(prevActive => { + return prevActive < 3 ? prevActive+1 : 0; + }); + setTimeout(() => { + setActive1(prevActive => { + return prevActive < 3 ? prevActive+1 : 0; + }); + }, 400); + }, 3000); + setIntervalId(interval); + } + }; + return (
{/* 主要内容区域 */} @@ -114,22 +139,24 @@ function Banner({isVisible}) {
{/* */} -
+
{bannerList[active].desc1} {/* 四张banner轮播 */}
{bannerList.map((item, index) => { - return
{item.title}
+ return
{ + setActive(index); + setTimeout(() => { + setActive1(index); + }, 200); + }}>{item.title}
})}
{bannerList[active].desc} - {/* */}
diff --git a/src/forge/Main/projecthome/v2/components/terminalAnimation2.jsx b/src/forge/Main/projecthome/v2/components/terminalAnimation2.jsx index 54964645c..81b52992e 100644 --- a/src/forge/Main/projecthome/v2/components/terminalAnimation2.jsx +++ b/src/forge/Main/projecthome/v2/components/terminalAnimation2.jsx @@ -10,18 +10,11 @@ const TerminalAnimation = ({ startAnimation = true, lines, width, height, class_ const animationRef = useRef(null); const keyColor = { - 'git clone': '#fff700', - 'git commit': '#fff700', - 'git log': '#fff700', - 'git merge': '#fff700', - 'git remote': '#fff700', - 'git pull': '#d24a6f', - 'git push': '#d24a6f', - 'git status': '#2977ff', - 'git fetch': '#2977ff', - 'git add': '#9aff41', - 'cd forgeplus': '#9aff41', - 'git checkout': '#9aff41' + 'if(!isVisible)': '#e5caff6a', + 'setInterval': '#e5caff6a', + 'clearInterval': '#e5caff6a', + 'const params': '#e5caff6a', + 'addComment': '#e5caff6a' }; const fontSize = 12;