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.
This commit is contained in:
CalciumIon
2024-12-12 20:52:22 +08:00
parent d241e4fe29
commit 16599a900b

View File

@@ -45,12 +45,8 @@ export const StyleProvider = ({ children }) => {
updateIsMobile(); updateIsMobile();
const updateShowSider = () => { const updateShowSider = () => {
if (isMobile()) {
dispatch({ type: 'SET_SIDER', payload: false });
} else {
// check pathname // check pathname
const pathname = window.location.pathname; const pathname = window.location.pathname;
console.log(pathname)
if (pathname === '' || pathname === '/' || pathname.includes('/home') || pathname.includes('/chat')) { if (pathname === '' || pathname === '/' || pathname.includes('/home') || pathname.includes('/chat')) {
dispatch({ type: 'SET_SIDER', payload: false }); dispatch({ type: 'SET_SIDER', payload: false });
dispatch({ type: 'SET_INNER_PADDING', payload: false }); dispatch({ type: 'SET_INNER_PADDING', payload: false });
@@ -58,6 +54,9 @@ export const StyleProvider = ({ children }) => {
dispatch({ type: 'SET_SIDER', payload: true }); dispatch({ type: 'SET_SIDER', payload: true });
dispatch({ type: 'SET_INNER_PADDING', payload: true }); dispatch({ type: 'SET_INNER_PADDING', payload: true });
} }
if (isMobile()) {
dispatch({ type: 'SET_SIDER', payload: false });
} }
}; };