/* 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 . For commercial licensing, please contact support@quantumnous.com */ import React, { useCallback, useEffect, useRef, useState } from 'react'; import { Banner, Button, Card, Spin } from '@/components/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, toBoolean } from '../../helpers'; const ProgressiveSettingsSections = ({ children, loading }) => { const sections = React.Children.toArray(children); const [visibleCount, setVisibleCount] = useState(1); useEffect(() => { if (visibleCount >= sections.length) return; // Yield between sections so mounting all forms cannot block one task. const timer = setTimeout(() => setVisibleCount((count) => count + 1), 0); return () => clearTimeout(timer); }, [visibleCount, sections.length]); return ( {sections.slice(0, visibleCount)} {visibleCount < sections.length && (
)}
); }; 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, /* Skill switches arrive as strings from the options API. */ SkillMarketRequireAuth: false, SkillInjectEnabled: false, SkillInjectMaxSkills: '5', SkillInjectMaxRunes: '3000', SkillInjectCacheTTLSeconds: '60', /* 监控设置 */ 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, }); const [loading, setLoading] = useState(true); const [optionsLoaded, setOptionsLoaded] = useState(false); const [loadError, setLoadError] = useState(''); const inputTypes = useRef(inputs); const getOptions = useCallback(async () => { const res = await API.get('/api/option/'); const { success, message, data } = res.data; if (success && Array.isArray(data)) { 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 { throw new Error(message || '运营设置读取失败,请重试'); } }, []); const onRefresh = useCallback(async () => { try { setLoading(true); setLoadError(''); await getOptions(); setOptionsLoaded(true); } catch (error) { setLoadError(error.message || '运营设置读取失败,请重试'); } finally { setLoading(false); } }, [getOptions]); useEffect(() => { onRefresh(); }, [onRefresh]); const errorBanner = loadError && ( ); // Never mount editable defaults when the initial request fails. if (!optionsLoaded) { if (loadError) return errorBanner; return ( ); } return ( <> {errorBanner} {/* 通用设置 */} {/* 语言与地区 */} {/* 主题色配置 */}
{/* 顶栏模块管理 */}
{/* 企业员工顶栏管理 */}
{/* 左侧边栏模块管理(管理员) */}
{/* 屏蔽词过滤设置 */} {/* 日志设置 */} {/* 监控设置 */} {/* 兜底渠道设置 */} {/* 技能注入(网关直连)设置 */} {/* 服务大盘监控设置 */}
{/* 额度设置 */} {/* 跑马灯设置 */} {/* 体验中心设置 */} {/* 普通管理员可见的系统设置页(权限下放) */}
); }; export default OperationSetting;