From cf46b89814258927fdbc6fc210233a9f86ffd104 Mon Sep 17 00:00:00 2001 From: t0ng7u Date: Wed, 16 Jul 2025 04:50:23 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=B9=20refactor(PageLayout):=20remove?= =?UTF-8?q?=20unused=20state=20variables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed unused `userState` and `statusState` bindings from `PageLayout.js` while retaining their dispatch functions for authentication and status management. Confirmed correct use of array destructuring to skip the unused toggle function returned by `useSidebarCollapsed`. This change introduces no functional differences and solely improves readability and maintainability. --- web/src/components/layout/PageLayout.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/web/src/components/layout/PageLayout.js b/web/src/components/layout/PageLayout.js index 044d0913..7ef42eb7 100644 --- a/web/src/components/layout/PageLayout.js +++ b/web/src/components/layout/PageLayout.js @@ -15,8 +15,8 @@ import { useLocation } from 'react-router-dom'; const { Sider, Content, Header } = Layout; const PageLayout = () => { - const [userState, userDispatch] = useContext(UserContext); - const [statusState, statusDispatch] = useContext(StatusContext); + const [, userDispatch] = useContext(UserContext); + const [, statusDispatch] = useContext(StatusContext); const isMobile = useIsMobile(); const [collapsed, , setCollapsed] = useSidebarCollapsed(); const [drawerOpen, setDrawerOpen] = useState(false); @@ -32,7 +32,6 @@ const PageLayout = () => { const isConsoleRoute = location.pathname.startsWith('/console'); const showSider = isConsoleRoute && (!isMobile || drawerOpen); - // Ensure sidebar not collapsed when opening drawer on mobile useEffect(() => { if (isMobile && drawerOpen && collapsed) { setCollapsed(false); @@ -76,7 +75,6 @@ const PageLayout = () => { linkElement.href = logo; } } - // 从localStorage获取上次使用的语言 const savedLang = localStorage.getItem('i18nextLng'); if (savedLang) { i18n.changeLanguage(savedLang); @@ -125,7 +123,6 @@ const PageLayout = () => { width: 'var(--sidebar-current-width)', }} > - {/* 在移动端点击菜单后关闭侧边栏 */} { if (isMobile) setDrawerOpen(false); }} /> )}