diff --git a/web/src/components/OperationSetting.js b/web/src/components/OperationSetting.js
index b9e8e9e..2dd5489 100644
--- a/web/src/components/OperationSetting.js
+++ b/web/src/components/OperationSetting.js
@@ -7,6 +7,7 @@ import SettingsSensitiveWords from '../pages/Setting/Operation/SettingsSensitive
import SettingsLog from '../pages/Setting/Operation/SettingsLog.js';
import SettingsDataDashboard from '../pages/Setting/Operation/SettingsDataDashboard.js';
import SettingsMonitoring from '../pages/Setting/Operation/SettingsMonitoring.js';
+import SettingsCreditLimit from '../pages/Setting/Operation/SettingsCreditLimit.js';
import {
API,
@@ -244,6 +245,10 @@ const OperationSetting = () => {
+ {/* 额度设置 */}
+
+
+
-
-
-
-
-
- {
- submitConfig('quota').then();
- }}
- >
- 保存额度设置
-
倍率设置
diff --git a/web/src/pages/Setting/Operation/SettingsCreditLimit.js b/web/src/pages/Setting/Operation/SettingsCreditLimit.js
new file mode 100644
index 0000000..4fcbb4e
--- /dev/null
+++ b/web/src/pages/Setting/Operation/SettingsCreditLimit.js
@@ -0,0 +1,156 @@
+import React, { useEffect, useState, useRef } from 'react';
+import { Button, Col, Form, Row, Spin } from '@douyinfe/semi-ui';
+import {
+ compareObjects,
+ API,
+ showError,
+ showSuccess,
+ showWarning,
+} from '../../../helpers';
+
+export default function SettingsCreditLimit(props) {
+ const [loading, setLoading] = useState(false);
+ const [inputs, setInputs] = useState({
+ QuotaForNewUser: '',
+ PreConsumedQuota: '',
+ QuotaForInviter: '',
+ QuotaForInvitee: '',
+ });
+ const refForm = useRef();
+ const [inputsRow, setInputsRow] = useState(inputs);
+
+ function onSubmit() {
+ const updateArray = compareObjects(inputs, inputsRow);
+ if (!updateArray.length) return showWarning('你似乎并没有修改什么');
+ const requestQueue = updateArray.map((item) => {
+ let value = '';
+ if (typeof inputs[item.key] === 'boolean') {
+ value = String(inputs[item.key]);
+ } else {
+ value = inputs[item.key];
+ }
+ return API.put('/api/option/', {
+ key: item.key,
+ value,
+ });
+ });
+ setLoading(true);
+ Promise.all(requestQueue)
+ .then((res) => {
+ if (requestQueue.length === 1) {
+ if (res.includes(undefined)) return;
+ } else if (requestQueue.length > 1) {
+ if (res.includes(undefined)) return showError('部分更新失败');
+ }
+ showSuccess('更新成功');
+ })
+ .catch(() => {
+ showError('更新失败');
+ })
+ .finally(() => {
+ setLoading(false);
+ setInputsRow(structuredClone(inputs));
+ });
+ }
+
+ useEffect(() => {
+ const currentInputs = {};
+ for (let key in props.options) {
+ if (Object.keys(inputs).includes(key)) {
+ currentInputs[key] = props.options[key];
+ }
+ }
+ setInputs(currentInputs);
+ setInputsRow(structuredClone(currentInputs));
+ refForm.current.setValues(currentInputs);
+ }, [props.options]);
+ return (
+ <>
+
+
+
+
+
+ setInputs({
+ ...inputs,
+ QuotaForNewUser: String(value),
+ })
+ }
+ />
+
+
+
+ setInputs({
+ ...inputs,
+ PreConsumedQuota: String(value),
+ })
+ }
+ />
+
+
+
+ setInputs({
+ ...inputs,
+ QuotaForInviter: String(value),
+ })
+ }
+ />
+
+
+
+ setInputs({
+ ...inputs,
+ QuotaForInvitee: String(value),
+ })
+ }
+ />
+
+
+
+
+
+
+
+
+
+ >
+ );
+}