diff --git a/web/src/components/HeaderBar.js b/web/src/components/HeaderBar.js
index 6234d867..1ddf24e9 100644
--- a/web/src/components/HeaderBar.js
+++ b/web/src/components/HeaderBar.js
@@ -124,11 +124,11 @@ const HeaderBar = () => {
return (
{
if (props.itemKey === 'home') {
- styleDispatch({ type: 'SET_INNER_PADDING', payload: true });
- styleDispatch({ type: 'SET_SIDER', payload: true });
- } else {
styleDispatch({ type: 'SET_INNER_PADDING', payload: false });
styleDispatch({ type: 'SET_SIDER', payload: false });
+ } else {
+ styleDispatch({ type: 'SET_INNER_PADDING', payload: true });
+ styleDispatch({ type: 'SET_SIDER', payload: true });
}
}}>
{
{
styleState.showSider ?
} theme="light" aria-label="展开侧边栏" onClick={
- () => styleDispatch({ type: 'SET_SIDER', payload: false })
+ () => styleDispatch({ type: 'SET_SIDER', payload: true })
} />:
} theme="light" aria-label="关闭侧边栏" onClick={
- () => styleDispatch({ type: 'SET_SIDER', payload: true })
+ () => styleDispatch({ type: 'SET_SIDER', payload: false })
} />
}
>
diff --git a/web/src/components/PageLayout.js b/web/src/components/PageLayout.js
index 6a8a9f1f..187ee15e 100644
--- a/web/src/components/PageLayout.js
+++ b/web/src/components/PageLayout.js
@@ -19,11 +19,11 @@ const PageLayout = () => {
- {styleState.showSider ? null : }
+ {styleState.showSider ? : null}
diff --git a/web/src/components/SiderBar.js b/web/src/components/SiderBar.js
index 0bad3142..603fa338 100644
--- a/web/src/components/SiderBar.js
+++ b/web/src/components/SiderBar.js
@@ -274,9 +274,9 @@ const SiderBar = () => {
items={headerButtons}
onSelect={(key) => {
if (key.itemKey.toString().startsWith('chat')) {
- styleDispatch({ type: 'SET_INNER_PADDING', payload: true });
- } else {
styleDispatch({ type: 'SET_INNER_PADDING', payload: false });
+ } else {
+ styleDispatch({ type: 'SET_INNER_PADDING', payload: true });
}
setSelectedKeys([key.itemKey]);
}}
diff --git a/web/src/context/Style/index.js b/web/src/context/Style/index.js
index 43206b43..46d5e6a1 100644
--- a/web/src/context/Style/index.js
+++ b/web/src/context/Style/index.js
@@ -44,6 +44,26 @@ export const StyleProvider = ({ children }) => {
updateIsMobile();
+ const updateShowSider = () => {
+ 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 });
+ }
+ }
+ };
+
+ updateShowSider()
+
+
// Optionally, add event listeners to handle window resize
window.addEventListener('resize', updateIsMobile);