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
bb45bf2f
authored
Mar 06, 2024
by
QuentinHsu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf(OtherSetting): code logic
parent
e82b5a21
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
28 deletions
+64
-28
web/src/components/OtherSetting.js
+64
-28
No files found.
web/src/components/OtherSetting.js
View file @
bb45bf2f
...
@@ -52,48 +52,84 @@ const OtherSetting = () => {
...
@@ -52,48 +52,84 @@ const OtherSetting = () => {
const
formAPISettingGeneral
=
useRef
();
const
formAPISettingGeneral
=
useRef
();
// 通用设置 - Notice
// 通用设置 - Notice
const
submitNotice
=
async
()
=>
{
const
submitNotice
=
async
()
=>
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
Notice
:
true
}));
try
{
await
updateOption
(
'Notice'
,
inputs
.
Notice
);
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
Notice
:
true
}));
showSuccess
(
'公告已更新'
);
await
updateOption
(
'Notice'
,
inputs
.
Notice
);
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
Notice
:
false
}));
showSuccess
(
'公告已更新'
);
}
catch
(
error
)
{
console
.
error
(
"公告更新失败"
,
error
);
showError
(
"公告更新失败"
)
}
finally
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
Notice
:
false
}));
}
};
};
// 个性化设置
// 个性化设置
const
formAPIPersonalization
=
useRef
();
const
formAPIPersonalization
=
useRef
();
// 个性化设置 - SystemName
// 个性化设置 - SystemName
const
submitSystemName
=
async
()
=>
{
const
submitSystemName
=
async
()
=>
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
SystemName
:
true
}));
try
{
await
updateOption
(
'SystemName'
,
inputs
.
SystemName
);
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
SystemName
:
true
}));
showSuccess
(
'系统名称已更新'
);
await
updateOption
(
'SystemName'
,
inputs
.
SystemName
);
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
SystemName
:
false
}));
showSuccess
(
'系统名称已更新'
);
}
catch
(
error
)
{
console
.
error
(
"系统名称更新失败"
,
error
);
showError
(
"系统名称更新失败"
)
}
finally
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
SystemName
:
false
}));
}
};
};
// Logo
//
个性化设置 -
Logo
const
submitLogo
=
async
()
=>
{
const
submitLogo
=
async
()
=>
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
Logo
:
true
}));
try
{
await
updateOption
(
'Logo'
,
inputs
.
Logo
);
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
Logo
:
true
}));
showSuccess
(
'Logo 已更新'
);
await
updateOption
(
'Logo'
,
inputs
.
Logo
);
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
Logo
:
false
}));
showSuccess
(
'Logo 已更新'
);
}
catch
(
error
)
{
console
.
error
(
"Logo 更新失败"
,
error
);
showError
(
"Logo 更新失败"
)
}
finally
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
Logo
:
false
}));
}
};
};
// 首页内容
//
个性化设置 -
首页内容
const
submitOption
=
async
(
key
)
=>
{
const
submitOption
=
async
(
key
)
=>
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
HomePageContent
:
true
}));
try
{
await
updateOption
(
key
,
inputs
[
key
]);
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
HomePageContent
:
true
}));
showSuccess
(
'首页内容已更新'
);
await
updateOption
(
key
,
inputs
[
key
]);
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
HomePageContent
:
false
}));
showSuccess
(
'首页内容已更新'
);
}
catch
(
error
)
{
console
.
error
(
"首页内容更新失败"
,
error
);
showError
(
"首页内容更新失败"
)
}
finally
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
HomePageContent
:
false
}));
}
};
};
// 关于
//
个性化设置 -
关于
const
submitAbout
=
async
()
=>
{
const
submitAbout
=
async
()
=>
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
About
:
true
}));
try
{
await
updateOption
(
'About'
,
inputs
.
About
);
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
About
:
true
}));
showSuccess
(
'关于内容已更新'
);
await
updateOption
(
'About'
,
inputs
.
About
);
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
About
:
false
}));
showSuccess
(
'关于内容已更新'
);
}
catch
(
error
)
{
console
.
error
(
"关于内容更新失败"
,
error
);
showError
(
"关于内容更新失败"
);
}
finally
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
About
:
false
}));
}
};
};
// 页脚
//
个性化设置 -
页脚
const
submitFooter
=
async
()
=>
{
const
submitFooter
=
async
()
=>
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
Footer
:
true
}));
try
{
await
updateOption
(
'Footer'
,
inputs
.
Footer
);
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
Footer
:
true
}));
showSuccess
(
'页脚内容已更新'
);
await
updateOption
(
'Footer'
,
inputs
.
Footer
);
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
Footer
:
false
}));
showSuccess
(
'页脚内容已更新'
);
}
catch
(
error
)
{
console
.
error
(
"页脚内容更新失败"
,
error
);
showError
(
"页脚内容更新失败"
);
}
finally
{
setLoadingInput
((
loadingInput
)
=>
({
...
loadingInput
,
Footer
:
false
}));
}
};
};
...
...
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