/* 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, { useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { ConsoleCard, ConsoleAlert, ConsoleTabs, } from '../../components/console/ConsolePrimitives'; import ProfileTable from '../../components/smart-router/ProfileTable'; import ConsentPanel from '../../components/smart-router/ConsentPanel'; import DecisionTable from '../../components/smart-router/DecisionTable'; import GlobalSettings from '../../components/smart-router/GlobalSettings'; import { isAdmin, isRoot } from '../../helpers'; import '../../components/smart-router/smart-router.css'; // 智能模型路由控制台页(docs/04-渠道与路由/19-智能模型路由方案.md §十二)。 // 页头、顶栏让位与内边距由 ConsolePageContainer 统一(CONSOLE_SPEC §1),页面不再自绘背景。 const SmartRouterPage = () => { const { t } = useTranslation(); const admin = isAdmin(); const root = isRoot(); const [tab, setTab] = useState(() => { try { return localStorage.getItem('smart_router_tab') || 'mine'; } catch (e) { return 'mine'; } }); const onTab = (k) => { setTab(k); try { localStorage.setItem('smart_router_tab', k); } catch (e) { /* 浏览器存储不可用时忽略 */ } }; const tabs = useMemo(() => { const list = [ { key: 'mine', title: t('我的集合') }, { key: 'consent', title: t('数据出境授权') }, { key: 'decisions', title: t('判定明细') }, ]; if (admin) { list.push({ key: 'system', title: t('平台集合') }); list.push({ key: 'all-decisions', title: t('全部判定明细') }); } if (root) list.push({ key: 'settings', title: t('全局设置') }); return list; }, [admin, root, t]); const activeKey = tabs.some((x) => x.key === tab) ? tab : 'mine'; return (
({ key: x.key, label: x.title }))} />
{activeKey === 'mine' && ( )} {activeKey === 'consent' && } {activeKey === 'decisions' && } {activeKey === 'system' && ( )} {activeKey === 'all-decisions' && } {activeKey === 'settings' && }
); }; export default SmartRouterPage;