From 93d9997fee73992b18cd7dba0c76f8b2132e68eb Mon Sep 17 00:00:00 2001 From: ZLY Date: Sun, 28 Sep 2025 16:52:20 +0800 Subject: [PATCH] =?UTF-8?q?style(sidebar):=20=E4=BC=98=E5=8C=96ResizeBox?= =?UTF-8?q?=E8=A1=8C=E5=86=85=E6=A0=B7=E5=BC=8F=E8=A6=86=E7=9B=96setSubMen?= =?UTF-8?q?u=E5=AF=BC=E8=87=B4=E6=8B=96=E5=8A=A8=E5=90=8E=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=BF=AE=E6=94=B9=E5=AE=BD=E5=BA=A6=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ideContainer/sideBar.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pages/ideContainer/sideBar.tsx b/src/pages/ideContainer/sideBar.tsx index 50e4375..7718d60 100644 --- a/src/pages/ideContainer/sideBar.tsx +++ b/src/pages/ideContainer/sideBar.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import styles from './style/sideBar.module.less'; import { ResizeBox, @@ -173,6 +173,7 @@ const SideBar: React.FC = ({ const [showModal, setShowModal] = useState(false); const [modalType, setModalType] = useState<'ADD' | 'EDIT'>('ADD'); const [currentApp, setCurrentApp] = useState(null); + const resizeBoxRef = useRef(null); // 引用第一个 ResizeBox 容器 const { menuData } = useSelector(state => state.ideContainer); const dispatch = useDispatch(); @@ -217,13 +218,14 @@ const SideBar: React.FC = ({ // 处理子菜单区域的拖拽调整大小 const handleSubMenuResize = (e: MouseEvent, { width }: { width: number }) => { - setSubMenuWidth(width); + resizeBoxRef.current.style.width = `${width}px`; }; // 切换子菜单区域的收起/展开状态 const toggleSubMenu = () => { setIsSubMenuCollapsed(!isSubMenuCollapsed); - setSubMenuWidth(isSubMenuCollapsed ? 300 : 0); + const width = isSubMenuCollapsed ? 300 : 0; + resizeBoxRef.current.style.width = `${width}px`; }; // 处理菜单项点击事件 @@ -237,7 +239,7 @@ const SideBar: React.FC = ({ // 如果点击的是其他菜单项,则展开子菜单(如果已收起) if (isSubMenuCollapsed) { setIsSubMenuCollapsed(false); - setSubMenuWidth(300); + resizeBoxRef.current.style.width = `300px`; } } @@ -420,6 +422,7 @@ const SideBar: React.FC = ({ ))}