From b27d70f0fc0a6c25badff160e4ca9c9b50bf3537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98937886381=E2=80=99?= <‘937886381@qq.com’> Date: Fri, 13 Sep 2024 16:52:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Common/forecastRect/index.jsx | 35 ++++++++++--------- .../components/forecastRightChart/index.jsx | 30 +++++++++++++--- .../components/forecastRightChart/yield.jsx | 28 +++++++++++++-- .../components/paramsInput/index.jsx | 5 +-- src/pages/Home/index.jsx | 2 +- 5 files changed, 74 insertions(+), 26 deletions(-) diff --git a/src/components/Common/forecastRect/index.jsx b/src/components/Common/forecastRect/index.jsx index ad4e2f2..1a27843 100644 --- a/src/components/Common/forecastRect/index.jsx +++ b/src/components/Common/forecastRect/index.jsx @@ -1,7 +1,7 @@ /* * @Author: zhp * @Date: 2024-08-29 09:46:11 - * @LastEditTime: 2024-09-13 14:35:10 + * @LastEditTime: 2024-09-13 16:27:51 * @LastEditors: zhp * @Description: */ @@ -25,15 +25,24 @@ function BlueRect(props) { // 在这里可以根据isVisible的变化执行其他逻辑 }; // const parentRef = useRef(null); - // const pointsRef = useRef(null); + // const pointsRef = useRef(null); + const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 }); + const [pointsPosition, setPointsPosition] = useState({ left: 'initial', top: 'initial' }); + + const handleMouseMove = (event) => { + setMousePosition({ x: event.clientX, y: event.clientY }); + }; + const handleToggleVisibility = () => { setIsVisible(!isVisible); if (isVisible) { - console.log(props) // 当隐藏时,可以清理一些数据 setChartData(null); } else { - console.log('props',props) + setPointsPosition({ + left: `${mousePosition.x + 100}px`, + top: `${mousePosition.y - 100}px`, + }); // 当显示时,可以模拟获取数据并传递给子组件 setChartData({ title, @@ -42,15 +51,8 @@ function BlueRect(props) { }); } } - // useEffect(() => { - // if (parentRef.current && pointsRef.current &&!props.blue && isVisible) { - // const parentRect = parentRef.current.getBoundingClientRect(); - // pointsRef.current.style.left = `${parentRect.right}px`; - // pointsRef.current.style.top = `${parentRect.top}px`; - // } - // }, [props.blue, isVisible]); return ( -