Initial import of weiyuan frontend
This commit is contained in:
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { Card, Spin } from '@douyinfe/semi-ui';
|
||||
import SettingsGeneral from '../../pages/Setting/Operation/SettingsGeneral';
|
||||
import SettingsLanguage from '../../pages/Setting/Operation/SettingsLanguage';
|
||||
import SettingsHeaderNavModules from '../../pages/Setting/Operation/SettingsHeaderNavModules';
|
||||
import SettingsOrgUserNavModules from '../../pages/Setting/Operation/SettingsOrgUserNavModules';
|
||||
import SettingsSidebarModulesAdmin from '../../pages/Setting/Operation/SettingsSidebarModulesAdmin';
|
||||
import SettingsSensitiveWords from '../../pages/Setting/Operation/SettingsSensitiveWords';
|
||||
import SettingsLog from '../../pages/Setting/Operation/SettingsLog';
|
||||
import SettingsMonitoring from '../../pages/Setting/Operation/SettingsMonitoring';
|
||||
import SettingsDashboardMonitor from '../../pages/Setting/Operation/SettingsDashboardMonitor';
|
||||
import SettingsCreditLimit from '../../pages/Setting/Operation/SettingsCreditLimit';
|
||||
import SettingsExperienceCenter from '../../pages/Setting/Operation/SettingsExperienceCenter';
|
||||
import SettingsMarquee from '../../pages/Setting/Operation/SettingsMarquee';
|
||||
import SettingsFallback from '../../pages/Setting/Operation/SettingsFallback';
|
||||
import SettingsTheme from '../../pages/Setting/Operation/SettingsTheme';
|
||||
import SettingsAdminDelegation from '../../pages/Setting/Operation/SettingsAdminDelegation';
|
||||
import SettingsSkillInject from '../../pages/Setting/Operation/SettingsSkillInject';
|
||||
import { API, showError, toBoolean } from '../../helpers';
|
||||
|
||||
const OperationSetting = () => {
|
||||
let [inputs, setInputs] = useState({
|
||||
/* 额度相关 */
|
||||
QuotaForNewUser: 0,
|
||||
PreConsumedQuota: 0,
|
||||
QuotaForInviter: 0,
|
||||
QuotaForInvitee: 0,
|
||||
'quota_setting.enable_free_model_pre_consume': true,
|
||||
/* 邀请消费返佣:布尔必须在此声明,getOptions 才会 toBoolean;
|
||||
否则读回字符串 "false" 被当真值,返佣开关恒显示开启且关不掉 */
|
||||
InviteRebateEnabled: false,
|
||||
|
||||
/* 通用设置 */
|
||||
TopUpLink: '',
|
||||
'general_setting.docs_link': '',
|
||||
QuotaPerUnit: 0,
|
||||
USDExchangeRate: 0,
|
||||
RetryTimes: 0,
|
||||
'general_setting.quota_display_type': 'USD',
|
||||
DisplayTokenStatEnabled: false,
|
||||
DefaultCollapseSidebar: false,
|
||||
DemoSiteEnabled: false,
|
||||
SelfUseModeEnabled: false,
|
||||
|
||||
/* 语言与地区(JSON,按 IP 国家自动选择界面语言) */
|
||||
LanguageSetting: '',
|
||||
|
||||
/* 腾讯云COS配置 */
|
||||
CosEnabled: false,
|
||||
CosSecretId: '',
|
||||
CosSecretKey: '',
|
||||
CosBucket: '',
|
||||
CosRegion: '',
|
||||
CosBaseUrl: '',
|
||||
|
||||
/* 顶栏模块管理 */
|
||||
HeaderNavModules: '',
|
||||
|
||||
/* 企业员工顶栏管理 */
|
||||
HeaderNavModulesOrgUser: '',
|
||||
|
||||
/* 左侧边栏模块管理(管理员) */
|
||||
SidebarModulesAdmin: '',
|
||||
|
||||
/* 主题色配置 */
|
||||
ThemeConfig: '',
|
||||
|
||||
/* 主题预设模板覆盖 */
|
||||
ThemePresets: '',
|
||||
|
||||
/* 敏感词设置 */
|
||||
CheckSensitiveEnabled: false,
|
||||
CheckSensitiveOnPromptEnabled: false,
|
||||
SensitiveWords: '',
|
||||
|
||||
/* 日志设置 */
|
||||
LogConsumeEnabled: false,
|
||||
|
||||
/* 提示词采集(实验性,方案 §35 一期) */
|
||||
GlobalPromptArchiveEnabled: false,
|
||||
|
||||
/* 监控设置 */
|
||||
ChannelDisableThreshold: 0,
|
||||
QuotaRemindThreshold: 0,
|
||||
AutomaticDisableChannelEnabled: false,
|
||||
AutomaticEnableChannelEnabled: false,
|
||||
ChannelServerErrorAutoDisableThreshold: '',
|
||||
AutomaticDisableKeywords: '',
|
||||
'monitor_setting.auto_test_channel_enabled': false,
|
||||
'monitor_setting.auto_test_channel_minutes': 10,
|
||||
ChannelAffinityEnabled: false,
|
||||
ChannelAffinityTTL: '',
|
||||
|
||||
/* 体验中心设置 */
|
||||
ExperienceCenterModels: '',
|
||||
|
||||
/* 跑马灯设置 */
|
||||
MarqueeContent: '',
|
||||
|
||||
/* 下放给普通管理员的系统设置 tab(JSON 数组字符串) */
|
||||
AdminDelegatedSettingTabs: '',
|
||||
|
||||
/* 兜底渠道设置(Phase 1-3)*/
|
||||
'fallback_setting.enabled': false,
|
||||
'fallback_setting.max_depth': 3,
|
||||
'fallback_setting.timeout_ms': 60000,
|
||||
'fallback_setting.total_timeout_ms': 180000,
|
||||
'fallback_setting.billing_mode': 'actual',
|
||||
'fallback_setting.edit_permission': 'root_only',
|
||||
'fallback_setting.allow_cross_group': false,
|
||||
'fallback_setting.cross_border_allowed': false,
|
||||
'fallback_setting.bound_user_allowed': false,
|
||||
'fallback_setting.cooling_seconds': 30,
|
||||
'fallback_setting.per_token_max_per_minute': 0,
|
||||
'fallback_setting.rollout_percent': 100,
|
||||
'fallback_setting.max_attempts_per_request': 10,
|
||||
});
|
||||
|
||||
let [loading, setLoading] = useState(false);
|
||||
const inputTypes = useRef(inputs);
|
||||
|
||||
const getOptions = useCallback(async () => {
|
||||
const res = await API.get('/api/option/');
|
||||
const { success, message, data } = res.data;
|
||||
if (success) {
|
||||
let newInputs = {};
|
||||
data.forEach((item) => {
|
||||
if (typeof inputTypes.current[item.key] === 'boolean') {
|
||||
newInputs[item.key] = toBoolean(item.value);
|
||||
} else {
|
||||
newInputs[item.key] = item.value;
|
||||
}
|
||||
});
|
||||
|
||||
setInputs(newInputs);
|
||||
} else {
|
||||
showError(message);
|
||||
}
|
||||
}, []);
|
||||
const onRefresh = useCallback(async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
await getOptions();
|
||||
// showSuccess('刷新成功');
|
||||
} catch (error) {
|
||||
showError('刷新失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [getOptions]);
|
||||
|
||||
useEffect(() => {
|
||||
onRefresh();
|
||||
}, [onRefresh]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Spin spinning={loading} size='large'>
|
||||
{/* 通用设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<SettingsGeneral options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 语言与地区 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<SettingsLanguage options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 主题色配置 */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<SettingsTheme options={inputs} refresh={onRefresh} />
|
||||
</div>
|
||||
{/* 顶栏模块管理 */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<SettingsHeaderNavModules options={inputs} refresh={onRefresh} />
|
||||
</div>
|
||||
{/* 企业员工顶栏管理 */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<SettingsOrgUserNavModules options={inputs} refresh={onRefresh} />
|
||||
</div>
|
||||
{/* 左侧边栏模块管理(管理员) */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<SettingsSidebarModulesAdmin options={inputs} refresh={onRefresh} />
|
||||
</div>
|
||||
{/* 屏蔽词过滤设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<SettingsSensitiveWords options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 日志设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<SettingsLog options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 监控设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<SettingsMonitoring options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 兜底渠道设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<SettingsFallback options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 技能注入(网关直连)设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<SettingsSkillInject options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 服务大盘监控设置 */}
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
<SettingsDashboardMonitor />
|
||||
</div>
|
||||
{/* 额度设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<SettingsCreditLimit options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 跑马灯设置 */}
|
||||
<Card style={{ marginTop: '10px' }}>
|
||||
<SettingsMarquee options={inputs} refresh={onRefresh} />
|
||||
</Card>
|
||||
{/* 体验中心设置 */}
|
||||
<SettingsExperienceCenter options={inputs} refresh={onRefresh} />
|
||||
{/* 普通管理员可见的系统设置页(权限下放) */}
|
||||
<SettingsAdminDelegation options={inputs} refresh={onRefresh} />
|
||||
</Spin>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default OperationSetting;
|
||||
Reference in New Issue
Block a user