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
7d8ca0b0
authored
Apr 01, 2024
by
QuentinHsu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf(Setting): add useEffect and useNavigate hooks to Setting component
parent
3af90390
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
10 deletions
+25
-10
web/src/pages/Setting/index.js
+25
-10
No files found.
web/src/pages/Setting/index.js
View file @
7d8ca0b0
import
React
,
{
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Layout
,
TabPane
,
Tabs
}
from
'@douyinfe/semi-ui'
;
import
{
useNavigate
,
useLocation
}
from
'react-router-dom'
;
import
SystemSetting
from
'../../components/SystemSetting'
;
import
SystemSetting
from
'../../components/SystemSetting'
;
import
{
isRoot
}
from
'../../helpers'
;
import
{
isRoot
}
from
'../../helpers'
;
import
OtherSetting
from
'../../components/OtherSetting'
;
import
OtherSetting
from
'../../components/OtherSetting'
;
import
PersonalSetting
from
'../../components/PersonalSetting'
;
import
PersonalSetting
from
'../../components/PersonalSetting'
;
import
OperationSetting
from
'../../components/OperationSetting'
;
import
OperationSetting
from
'../../components/OperationSetting'
;
import
{
Layout
,
TabPane
,
Tabs
}
from
'@douyinfe/semi-ui'
;
const
Setting
=
()
=>
{
const
Setting
=
()
=>
{
const
navigate
=
useNavigate
();
const
location
=
useLocation
();
const
[
tabActiveKey
,
setTabActiveKey
]
=
useState
(
'1'
);
const
[
tabActiveKey
,
setTabActiveKey
]
=
useState
(
'1'
);
let
panes
=
[
let
panes
=
[
{
{
tab
:
'个人设置'
,
tab
:
'个人设置'
,
content
:
<
PersonalSetting
/>
,
content
:
<
PersonalSetting
/>
,
itemKey
:
'
1
'
,
itemKey
:
'
personal
'
,
},
},
];
];
...
@@ -20,28 +23,40 @@ const Setting = () => {
...
@@ -20,28 +23,40 @@ const Setting = () => {
panes
.
push
({
panes
.
push
({
tab
:
'运营设置'
,
tab
:
'运营设置'
,
content
:
<
OperationSetting
/>
,
content
:
<
OperationSetting
/>
,
itemKey
:
'
2
'
,
itemKey
:
'
operation
'
,
});
});
panes
.
push
({
panes
.
push
({
tab
:
'系统设置'
,
tab
:
'系统设置'
,
content
:
<
SystemSetting
/>
,
content
:
<
SystemSetting
/>
,
itemKey
:
'
3
'
,
itemKey
:
'
system
'
,
});
});
panes
.
push
({
panes
.
push
({
tab
:
'其他设置'
,
tab
:
'其他设置'
,
content
:
<
OtherSetting
/>
,
content
:
<
OtherSetting
/>
,
itemKey
:
'
4
'
,
itemKey
:
'
other
'
,
});
});
}
}
const
onChangeTab
=
(
key
)
=>
{
setTabActiveKey
(
key
);
navigate
(
`?tab=
${
key
}
`
);
};
useEffect
(()
=>
{
const
searchParams
=
new
URLSearchParams
(
window
.
location
.
search
);
const
tab
=
searchParams
.
get
(
'tab'
);
if
(
tab
)
{
setTabActiveKey
(
tab
);
}
else
{
onChangeTab
(
'personal'
);
}
},
[
location
.
search
]);
return
(
return
(
<
div
>
<
div
>
<
Layout
>
<
Layout
>
<
Layout
.
Content
>
<
Layout
.
Content
>
<
Tabs
<
Tabs
type
=
'line'
type
=
'line'
defaultActiveKey
=
'1'
activeKey
=
{
tabActiveKey
}
onChange
=
{(
key
)
=>
setTabActiveKey
(
key
)}
onChange
=
{(
key
)
=>
onChangeTab
(
key
)}
>
>
{
panes
.
map
((
pane
)
=>
(
{
panes
.
map
((
pane
)
=>
(
<
TabPane
itemKey
=
{
pane
.
itemKey
}
tab
=
{
pane
.
tab
}
key
=
{
pane
.
itemKey
}
>
<
TabPane
itemKey
=
{
pane
.
itemKey
}
tab
=
{
pane
.
tab
}
key
=
{
pane
.
itemKey
}
>
...
...
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