/* 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, { useEffect, useState } from 'react'; import { Layout, TabPane, Tabs } from '@douyinfe/semi-ui'; import { useNavigate, useLocation } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { Settings, Calculator, Gauge, Shapes, Cog, MoreHorizontal, LayoutDashboard, MessageSquare, Palette, CreditCard, } from 'lucide-react'; import SystemSetting from '../../components/settings/SystemSetting'; import { isRoot } from '../../helpers'; import OtherSetting from '../../components/settings/OtherSetting'; import OperationSetting from '../../components/settings/OperationSetting'; import RateLimitSetting from '../../components/settings/RateLimitSetting'; import ModelSetting from '../../components/settings/ModelSetting'; import DashboardSetting from '../../components/settings/DashboardSetting'; import RatioSetting from '../../components/settings/RatioSetting'; import ChatsSetting from '../../components/settings/ChatsSetting'; import DrawingSetting from '../../components/settings/DrawingSetting'; import PaymentSetting from '../../components/settings/PaymentSetting'; const Setting = () => { const { t } = useTranslation(); const navigate = useNavigate(); const location = useLocation(); const [tabActiveKey, setTabActiveKey] = useState('1'); let panes = []; if (isRoot()) { panes.push({ tab: ( {t('运营设置')} ), content: , itemKey: 'operation', }); panes.push({ tab: ( {t('仪表盘设置')} ), content: , itemKey: 'dashboard', }); panes.push({ tab: ( {t('聊天设置')} ), content: , itemKey: 'chats', }); panes.push({ tab: ( {t('绘图设置')} ), content: , itemKey: 'drawing', }); panes.push({ tab: ( {t('支付设置')} ), content: , itemKey: 'payment', }); panes.push({ tab: ( {t('分组与模型定价设置')} ), content: , itemKey: 'ratio', }); panes.push({ tab: ( {t('速率限制设置')} ), content: , itemKey: 'ratelimit', }); panes.push({ tab: ( {t('模型相关设置')} ), content: , itemKey: 'models', }); panes.push({ tab: ( {t('系统设置')} ), content: , itemKey: 'system', }); panes.push({ tab: ( {t('其他设置')} ), content: , itemKey: 'other', }); } const onChangeTab = (key) => { setTabActiveKey(key); navigate(`?tab=${key}`); }; useEffect(() => { const searchParams = new URLSearchParams(window.location.search); const tab = searchParams.get('tab'); if (tab) { setTabActiveKey(tab); } else { onChangeTab('operation'); } }, [location.search]); return (
onChangeTab(key)} > {panes.map((pane) => ( {tabActiveKey === pane.itemKey && pane.content} ))}
); }; export default Setting;