Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e28ad368
authored
Mar 10, 2025
by
1808837298@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: Improve mobile responsiveness and scrolling behavior in UI layout
parent
58b8ca90
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
16 deletions
+32
-16
web/src/components/PageLayout.js
+11
-3
web/src/components/SiderBar.js
+3
-1
web/src/context/Style/index.js
+18
-12
No files found.
web/src/components/PageLayout.js
View file @
e28ad368
...
@@ -84,7 +84,11 @@ const PageLayout = () => {
...
@@ -84,7 +84,11 @@ const PageLayout = () => {
}}
>
}}
>
<
HeaderBar
/>
<
HeaderBar
/>
<
/Header
>
<
/Header
>
<
Layout
style
=
{{
marginTop
:
'56px'
,
height
:
'calc(100vh - 56px)'
,
overflow
:
'hidden'
}}
>
<
Layout
style
=
{{
marginTop
:
'56px'
,
height
:
'calc(100vh - 56px)'
,
overflow
:
styleState
.
isMobile
?
'auto'
:
'hidden'
}}
>
{
styleState
.
showSider
&&
(
{
styleState
.
showSider
&&
(
<
Sider
style
=
{{
<
Sider
style
=
{{
height
:
'calc(100vh - 56px)'
,
height
:
'calc(100vh - 56px)'
,
...
@@ -105,13 +109,17 @@ const PageLayout = () => {
...
@@ -105,13 +109,17 @@ const PageLayout = () => {
)}
)}
<
Layout
style
=
{{
<
Layout
style
=
{{
marginLeft
:
styleState
.
showSider
?
(
isSidebarCollapsed
?
'60px'
:
'200px'
)
:
'0'
,
marginLeft
:
styleState
.
showSider
?
(
isSidebarCollapsed
?
'60px'
:
'200px'
)
:
'0'
,
transition
:
'margin-left 0.3s ease'
transition
:
'margin-left 0.3s ease'
,
height
:
'100%'
,
overflow
:
'auto'
}}
>
}}
>
<
Content
<
Content
style
=
{{
style
=
{{
height
:
'100%'
,
height
:
'100%'
,
overflowY
:
'auto'
,
overflowY
:
'auto'
,
padding
:
styleState
.
shouldInnerPadding
?
'24px'
:
'0'
WebkitOverflowScrolling
:
'touch'
,
padding
:
styleState
.
shouldInnerPadding
?
'24px'
:
'0'
,
position
:
'relative'
}}
}}
>
>
<
App
/>
<
App
/>
...
...
web/src/components/SiderBar.js
View file @
e28ad368
...
@@ -305,7 +305,9 @@ const SiderBar = () => {
...
@@ -305,7 +305,9 @@ const SiderBar = () => {
borderRadius
:
'0 8px 8px 0'
,
borderRadius
:
'0 8px 8px 0'
,
transition
:
'all 0.3s ease'
,
transition
:
'all 0.3s ease'
,
position
:
'relative'
,
position
:
'relative'
,
zIndex
:
95
zIndex
:
95
,
overflowY
:
'auto'
,
WebkitOverflowScrolling
:
'touch'
// Improve scrolling on iOS devices
}}
}}
defaultIsCollapsed
=
{
defaultIsCollapsed
=
{
localStorage
.
getItem
(
'default_collapse_sidebar'
)
===
'true'
localStorage
.
getItem
(
'default_collapse_sidebar'
)
===
'true'
...
...
web/src/context/Style/index.js
View file @
e28ad368
...
@@ -9,7 +9,7 @@ export const StyleContext = React.createContext({
...
@@ -9,7 +9,7 @@ export const StyleContext = React.createContext({
export
const
StyleProvider
=
({
children
})
=>
{
export
const
StyleProvider
=
({
children
})
=>
{
const
[
state
,
setState
]
=
useState
({
const
[
state
,
setState
]
=
useState
({
isMobile
:
false
,
isMobile
:
isMobile
()
,
showSider
:
false
,
showSider
:
false
,
shouldInnerPadding
:
false
,
shouldInnerPadding
:
false
,
});
});
...
@@ -39,7 +39,13 @@ export const StyleProvider = ({ children }) => {
...
@@ -39,7 +39,13 @@ export const StyleProvider = ({ children }) => {
useEffect
(()
=>
{
useEffect
(()
=>
{
const
updateIsMobile
=
()
=>
{
const
updateIsMobile
=
()
=>
{
dispatch
({
type
:
'SET_MOBILE'
,
payload
:
isMobile
()
});
const
mobileDetected
=
isMobile
();
dispatch
({
type
:
'SET_MOBILE'
,
payload
:
mobileDetected
});
// If on mobile, we might want to auto-hide the sidebar
if
(
mobileDetected
&&
state
.
showSider
)
{
dispatch
({
type
:
'SET_SIDER'
,
payload
:
false
});
}
};
};
updateIsMobile
();
updateIsMobile
();
...
@@ -51,24 +57,24 @@ export const StyleProvider = ({ children }) => {
...
@@ -51,24 +57,24 @@ export const StyleProvider = ({ children }) => {
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
});
}
else
{
}
else
{
dispatch
({
type
:
'SET_SIDER'
,
payload
:
true
});
// Only show sidebar on non-mobile devices by default
dispatch
({
type
:
'SET_SIDER'
,
payload
:
!
isMobile
()
});
dispatch
({
type
:
'SET_INNER_PADDING'
,
payload
:
true
});
dispatch
({
type
:
'SET_INNER_PADDING'
,
payload
:
true
});
}
}
if
(
isMobile
())
{
dispatch
({
type
:
'SET_SIDER'
,
payload
:
false
});
}
};
};
updateShowSider
()
updateShowSider
();
// Optionally, add event listeners to handle window resize
// Add event listeners to handle window resize
window
.
addEventListener
(
'resize'
,
updateIsMobile
);
const
handleResize
=
()
=>
{
updateIsMobile
();
};
window
.
addEventListener
(
'resize'
,
handleResize
);
// Cleanup event listener on component unmount
// Cleanup event listener on component unmount
return
()
=>
{
return
()
=>
{
window
.
removeEventListener
(
'resize'
,
updateIsMobil
e
);
window
.
removeEventListener
(
'resize'
,
handleResiz
e
);
};
};
},
[]);
},
[]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment