增加鼠标切换显示交互

This commit is contained in:
谢思 2026-03-14 09:58:29 +08:00
parent 2c40557c3d
commit 1c66354b94
2 changed files with 58 additions and 12 deletions

View File

@ -1,39 +1,72 @@
import React, { useCallback, useEffect, useState } from 'react';
import React, { useEffect, useState, useRef } from 'react';
import img11 from '../image/img11.png';
import img12 from '../image/img12.png';
import { Button } from 'antd';
import { rollingButton } from '../../../../../components/button';
function SoftwareFactory() {
const [active, setActive] = useState(1);
const [isTimerRunning, setIsTimerRunning] = useState(true);
const timerRef = useRef(null);
useEffect(() => {
const interval = setInterval(() => {
setActive(prevActive => {
return prevActive === 1 ? 2 : 1;
});
//
timerRef.current = setInterval(() => {
setActive(prevActive => prevActive === 1 ? 2 : 1);
}, 6000);
//
//
return () => {
clearInterval(interval);
if (timerRef.current) {
clearInterval(timerRef.current);
}
};
}, []);
//
const handleToggle = (mode) => {
setActive(mode);
if (timerRef.current) {
clearInterval(timerRef.current);
timerRef.current = null;
}
setIsTimerRunning(false);
};
//
const handleMouseLeave = () => {
if (!timerRef.current) {
timerRef.current = setInterval(() => {
setActive(prevActive => prevActive === 1 ? 2 : 1);
}, 6000);
setIsTimerRunning(true);
}
};
return (
<div className="software-factory home_v2_child" id="home_v2_child4">
<div className="title_v2 mb30">软件工厂</div>
<div className={`width1600 df software-factory-content software-factory-${active}`}>
<div
className={`width1600 df software-factory-content software-factory-${active}`}
onMouseLeave={handleMouseLeave}
>
<div className='software-left'>
<div className='software-left-border'>
<div className={`mb60 software-left-item ${active === 1 ? 'active' : ''}`}>
<div
className={`mb60 software-left-item ${active === 1 ? !isTimerRunning ? 'isTimerRunning' : 'active' : ''}`}
onClick={() => handleToggle(1)}
style={{ cursor: 'pointer' }}
>
<div className='font-26 font-bd'>
敏捷模式
<span className='ml12'>全流程迭代演化<i className='iconfont icon-a-zu15512 font-14'></i></span>
</div>
<div className='font-16'>敏捷模式聚焦需求 - 任务 - 代码 - 迭代 - 测试 - 制品的全流程<br />数字化升级和在线化组织</div>
</div>
<div className={`software-left-item ${active === 2 ? 'active' : ''}`}>
<div
className={`software-left-item ${active === 2 ? !isTimerRunning ? 'isTimerRunning' : 'active' : ''}`}
onClick={() => handleToggle(2)}
style={{ cursor: 'pointer' }}
>
<div className='font-26 font-bd'>
极速模式
<span className='ml12'>高效率快速响应<i className='iconfont icon-a-zu15512 font-14'></i></span>
@ -46,7 +79,6 @@ function SoftwareFactory() {
<div className='flex1'>
<img src={active === 1 ? img11 : img12} alt='' />
</div>
{/* 角标 */}
<div className='mode-tag font-16 font-bd color-white'>{active === 1 ? "敏捷模式" : "极速模式"}</div>
</div>
</div>

View File

@ -829,6 +829,20 @@
animation: height0-83 5.9s linear 0s infinite;
}
}
&.isTimerRunning{
position: relative;
&::before {
content: '';
position: absolute;
top: 12px;
left: -12px;
width: 1.5px;
height: 83%;
background-color: rgba(9, 18, 33, 1);
}
}
.icon-a-zu15512 {
position: relative;