fix: fix option update logic not working properly

This commit is contained in:
JustSong
2023-05-16 09:53:21 +08:00
parent e495960d0e
commit 8996737643
2 changed files with 6 additions and 8 deletions

View File

@@ -10,7 +10,6 @@ const OtherSetting = () => {
About: '',
HomePageLink: '',
});
let originInputs = {};
let [loading, setLoading] = useState(false);
const [showUpdateModal, setShowUpdateModal] = useState(false);
const [updateData, setUpdateData] = useState({
@@ -19,7 +18,7 @@ const OtherSetting = () => {
});
const getOptions = async () => {
const res = await API.get('/api/option');
const res = await API.get('/api/option/');
const { success, message, data } = res.data;
if (success) {
let newInputs = {};
@@ -29,7 +28,6 @@ const OtherSetting = () => {
}
});
setInputs(newInputs);
originInputs = newInputs;
} else {
showError(message);
}
@@ -41,7 +39,7 @@ const OtherSetting = () => {
const updateOption = async (key, value) => {
setLoading(true);
const res = await API.put('/api/option', {
const res = await API.put('/api/option/', {
key,
value,
});

View File

@@ -28,11 +28,11 @@ const SystemSetting = () => {
MessagePersistenceEnabled: '',
MessageRenderEnabled: '',
});
let originInputs = {};
const [originInputs, setOriginInputs] = useState({});
let [loading, setLoading] = useState(false);
const getOptions = async () => {
const res = await API.get('/api/option');
const res = await API.get('/api/option/');
const { success, message, data } = res.data;
if (success) {
let newInputs = {};
@@ -40,7 +40,7 @@ const SystemSetting = () => {
newInputs[item.key] = item.value;
});
setInputs(newInputs);
originInputs = newInputs;
setOriginInputs(newInputs);
} else {
showError(message);
}
@@ -67,7 +67,7 @@ const SystemSetting = () => {
default:
break;
}
const res = await API.put('/api/option', {
const res = await API.put('/api/option/', {
key,
value,
});