mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-17 20:07:26 +00:00
- Added new components for GroupRatioSettings and ModelRatioSettings to manage group and model ratios. - Integrated tabs in OperationSetting to switch between model and visual ratio settings. - Updated translations for new settings and improved existing ones in the English locale file. - Refactored ModelSettingsVisualEditor to support dynamic pricing and ratio configurations. This update improves the user interface for managing operational settings, enhancing usability and localization support.
167 lines
5.6 KiB
JavaScript
167 lines
5.6 KiB
JavaScript
import React, { useEffect, useState } from 'react';
|
|
import { Card, Spin, Tabs } from '@douyinfe/semi-ui';
|
|
import SettingsGeneral from '../pages/Setting/Operation/SettingsGeneral.js';
|
|
import SettingsDrawing from '../pages/Setting/Operation/SettingsDrawing.js';
|
|
import SettingsSensitiveWords from '../pages/Setting/Operation/SettingsSensitiveWords.js';
|
|
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 SettingsMagnification from '../pages/Setting/Operation/SettingsMagnification.js';
|
|
import ModelSettingsVisualEditor from '../pages/Setting/Operation/ModelSettingsVisualEditor.js';
|
|
import GroupRatioSettings from '../pages/Setting/Operation/GroupRatioSettings.js';
|
|
import ModelRatioSettings from '../pages/Setting/Operation/ModelRatioSettings.js';
|
|
|
|
|
|
import { API, showError, showSuccess } from '../helpers';
|
|
import SettingsChats from '../pages/Setting/Operation/SettingsChats.js';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
const OperationSetting = () => {
|
|
const { t } = useTranslation();
|
|
let [inputs, setInputs] = useState({
|
|
QuotaForNewUser: 0,
|
|
QuotaForInviter: 0,
|
|
QuotaForInvitee: 0,
|
|
QuotaRemindThreshold: 0,
|
|
PreConsumedQuota: 0,
|
|
StreamCacheQueueLength: 0,
|
|
ModelRatio: '',
|
|
CompletionRatio: '',
|
|
ModelPrice: '',
|
|
GroupRatio: '',
|
|
UserUsableGroups: '',
|
|
TopUpLink: '',
|
|
ChatLink: '',
|
|
ChatLink2: '', // 添加的新状态变量
|
|
QuotaPerUnit: 0,
|
|
AutomaticDisableChannelEnabled: false,
|
|
AutomaticEnableChannelEnabled: false,
|
|
ChannelDisableThreshold: 0,
|
|
LogConsumeEnabled: false,
|
|
DisplayInCurrencyEnabled: false,
|
|
DisplayTokenStatEnabled: false,
|
|
CheckSensitiveEnabled: false,
|
|
CheckSensitiveOnPromptEnabled: false,
|
|
CheckSensitiveOnCompletionEnabled: '',
|
|
StopOnSensitiveEnabled: '',
|
|
SensitiveWords: '',
|
|
MjNotifyEnabled: false,
|
|
MjAccountFilterEnabled: false,
|
|
MjModeClearEnabled: false,
|
|
MjForwardUrlEnabled: false,
|
|
MjActionCheckSuccessEnabled: false,
|
|
DrawingEnabled: false,
|
|
DataExportEnabled: false,
|
|
DataExportDefaultTime: 'hour',
|
|
DataExportInterval: 5,
|
|
DefaultCollapseSidebar: false, // 默认折叠侧边栏
|
|
RetryTimes: 0,
|
|
Chats: "[]",
|
|
});
|
|
|
|
let [loading, setLoading] = useState(false);
|
|
|
|
const getOptions = async () => {
|
|
const res = await API.get('/api/option/');
|
|
const { success, message, data } = res.data;
|
|
if (success) {
|
|
let newInputs = {};
|
|
data.forEach((item) => {
|
|
if (
|
|
item.key === 'ModelRatio' ||
|
|
item.key === 'GroupRatio' ||
|
|
item.key === 'UserUsableGroups' ||
|
|
item.key === 'CompletionRatio' ||
|
|
item.key === 'ModelPrice'
|
|
) {
|
|
item.value = JSON.stringify(JSON.parse(item.value), null, 2);
|
|
}
|
|
if (
|
|
item.key.endsWith('Enabled') ||
|
|
['DefaultCollapseSidebar'].includes(item.key)
|
|
) {
|
|
newInputs[item.key] = item.value === 'true' ? true : false;
|
|
} else {
|
|
newInputs[item.key] = item.value;
|
|
}
|
|
});
|
|
|
|
setInputs(newInputs);
|
|
} else {
|
|
showError(message);
|
|
}
|
|
};
|
|
async function onRefresh() {
|
|
try {
|
|
setLoading(true);
|
|
await getOptions();
|
|
// showSuccess('刷新成功');
|
|
} catch (error) {
|
|
showError('刷新失败');
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
}
|
|
|
|
useEffect(() => {
|
|
onRefresh();
|
|
}, []);
|
|
|
|
return (
|
|
<>
|
|
<Spin spinning={loading} size='large'>
|
|
{/* 通用设置 */}
|
|
<Card style={{ marginTop: '10px' }}>
|
|
<SettingsGeneral options={inputs} refresh={onRefresh} />
|
|
</Card>
|
|
{/* 绘图设置 */}
|
|
<Card style={{ marginTop: '10px' }}>
|
|
<SettingsDrawing options={inputs} refresh={onRefresh} />
|
|
</Card>
|
|
{/* 屏蔽词过滤设置 */}
|
|
<Card style={{ marginTop: '10px' }}>
|
|
<SettingsSensitiveWords options={inputs} refresh={onRefresh} />
|
|
</Card>
|
|
{/* 日志设置 */}
|
|
<Card style={{ marginTop: '10px' }}>
|
|
<SettingsLog options={inputs} refresh={onRefresh} />
|
|
</Card>
|
|
{/* 数据看板 */}
|
|
<Card style={{ marginTop: '10px' }}>
|
|
<SettingsDataDashboard options={inputs} refresh={onRefresh} />
|
|
</Card>
|
|
{/* 监控设置 */}
|
|
<Card style={{ marginTop: '10px' }}>
|
|
<SettingsMonitoring options={inputs} refresh={onRefresh} />
|
|
</Card>
|
|
{/* 额度设置 */}
|
|
<Card style={{ marginTop: '10px' }}>
|
|
<SettingsCreditLimit options={inputs} refresh={onRefresh} />
|
|
</Card>
|
|
{/* 聊天设置 */}
|
|
<Card style={{ marginTop: '10px' }}>
|
|
<SettingsChats options={inputs} refresh={onRefresh} />
|
|
</Card>
|
|
{/* 分组倍率设置 */}
|
|
<Card style={{ marginTop: '10px' }}>
|
|
<GroupRatioSettings options={inputs} refresh={onRefresh} />
|
|
</Card>
|
|
{/* 合并模型倍率设置和可视化倍率设置 */}
|
|
<Card style={{ marginTop: '10px' }}>
|
|
<Tabs type="line">
|
|
<Tabs.TabPane tab={t('模型倍率设置')} itemKey="model">
|
|
<ModelRatioSettings options={inputs} refresh={onRefresh} />
|
|
</Tabs.TabPane>
|
|
<Tabs.TabPane tab={t('可视化倍率设置')} itemKey="visual">
|
|
<ModelSettingsVisualEditor options={inputs} refresh={onRefresh} />
|
|
</Tabs.TabPane>
|
|
</Tabs>
|
|
</Card>
|
|
</Spin>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default OperationSetting;
|