From 16599a900bef1821ece120d2e0f21986ea11490f Mon Sep 17 00:00:00 2001 From: CalciumIon <1808837298@qq.com> Date: Thu, 12 Dec 2024 20:52:22 +0800 Subject: [PATCH] fix: Refine sider visibility and inner padding logic in StyleProvider component - Consolidated the logic for managing sider visibility and inner padding based on the current pathname, improving responsiveness to navigation changes. - Ensured that the sider is hidden on specific paths and adjusted inner padding accordingly, enhancing the user interface experience on both mobile and desktop views. --- web/src/context/Style/index.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/web/src/context/Style/index.js b/web/src/context/Style/index.js index 46d5e6a1..c3f28e62 100644 --- a/web/src/context/Style/index.js +++ b/web/src/context/Style/index.js @@ -45,19 +45,18 @@ export const StyleProvider = ({ children }) => { updateIsMobile(); const updateShowSider = () => { + // check pathname + const pathname = window.location.pathname; + if (pathname === '' || pathname === '/' || pathname.includes('/home') || pathname.includes('/chat')) { + dispatch({ type: 'SET_SIDER', payload: false }); + dispatch({ type: 'SET_INNER_PADDING', payload: false }); + } else { + dispatch({ type: 'SET_SIDER', payload: true }); + dispatch({ type: 'SET_INNER_PADDING', payload: true }); + } + if (isMobile()) { dispatch({ type: 'SET_SIDER', payload: false }); - } else { - // check pathname - const pathname = window.location.pathname; - console.log(pathname) - if (pathname === '' || pathname === '/' || pathname.includes('/home') || pathname.includes('/chat')) { - dispatch({ type: 'SET_SIDER', payload: false }); - dispatch({ type: 'SET_INNER_PADDING', payload: false }); - } else { - dispatch({ type: 'SET_SIDER', payload: true }); - dispatch({ type: 'SET_INNER_PADDING', payload: true }); - } } };