/* 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, { useContext } from 'react'; import { Navigate, useLocation, useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { BrainCircuit, Image, Video } from 'lucide-react'; import { StatusContext } from '../../context/Status'; import PageBackground from '../../components/common/PageBackground'; import TextModel from './components/TextModel'; import ImageGeneration from './components/ImageGeneration'; import VideoGeneration from './components/VideoGeneration'; import KeyManagement from './components/KeyManagement'; import ExperienceSidebar from './components/ExperienceSidebar'; import CloudBrain from '../CloudBrain'; import { CLOUD_BRAIN_UI_ENABLED } from '../../config/cloudBrainUi'; import Loading from '../../components/common/ui/Loading'; import { DEFAULT_LOGIN_REDIRECT } from '../../helpers/data'; import { EXPERIENCE_MODULES, useExperienceModules, } from './useExperienceModules'; // 移动端底部导航组件 const MobileBottomNav = ({ currentPath, navigate, isAvailable }) => { const { t } = useTranslation(); // 与桌面侧边栏共用 useExperienceModules 判定,运营关闭的子页两端一致隐藏 const navItems = [ { key: 'cloud-brain', configKey: 'cloudBrain', icon: BrainCircuit, label: t('云端大脑'), path: '/experience-center/cloud-brain', gradient: 'from-emerald-600 to-orange-500', beta: true, }, { key: 'image', configKey: 'imageGeneration', icon: Image, label: t('图片'), path: '/experience-center/image-generation', gradient: 'from-pink-500 to-rose-600', }, { key: 'video', configKey: 'videoGeneration', icon: Video, label: t('视频'), path: '/experience-center/video-generation', gradient: 'from-cyan-500 to-blue-600', }, ].filter((item) => isAvailable(item.configKey)); return (
{navItems.map((item) => { const isActive = currentPath.includes(item.key); const IconComponent = item.icon; return ( ); })}
); }; const ExperienceCenter = () => { const location = useLocation(); const navigate = useNavigate(); const [statusState] = useContext(StatusContext); const { ready, orgOnly, isAvailable, defaultPath } = useExperienceModules(); // 跑马灯公告是否存在(用于动态计算顶部间距) const hasMarquee = !!statusState?.status?.marquee_content?.trim(); // 默认落地:进第一个对当前用户可用的子页;一个都没有时,org_only 用户回企业 // 空间,其余用户去默认登录落地页。兜底目标都不在体验中心内,不会重定向循环。 const fallbackPath = defaultPath || (orgOnly ? '/org' : DEFAULT_LOGIN_REDIRECT); const isEntryPath = [ '/experience-center', '/experience-center/', // 兼容旧路由 '/experience-center/ai-creation', ].includes(location.pathname); if (isEntryPath) { // 配置/登录态就绪前不判定:默认配置全开,抢跑会落到随后才知道已关闭的页 return ready ? : ; } // 运营关闭(或分组不可见、org_only 被后端拦截)的子页,直达链接也转去可用页, // 避免停在菜单里看不到、接口又全报错的页面。大模型体验不在 EXPERIENCE_MODULES // 中,旧链接仍可直达。 const currentModule = EXPERIENCE_MODULES.find((m) => location.pathname.startsWith(m.path), ); if (ready && currentModule && !isAvailable(currentModule.configKey)) { return ; } const isTextModel = location.pathname.includes('text-model'); const isCloudBrain = location.pathname.includes('cloud-brain'); const isVideoGeneration = location.pathname.includes('video-generation'); const isImageGeneration = location.pathname.includes('image-generation'); // 这些页面内部有自己的滚动容器,不需要外层的 overflow-y-auto const noPadding = isTextModel || isCloudBrain || isVideoGeneration || isImageGeneration; if (!CLOUD_BRAIN_UI_ENABLED && isCloudBrain) { return ; } return (
{/* Sidebar - 桌面端 */}
{/* Main Content */}
{/* 统一页面背景层 —— 除 text-model 外,ExperienceCenter 是其子页面的唯一背景来源, * 子组件不再各自渲染背景,避免双层叠加。 * text-model 特例:TextModel 自带 via-white 亮底保证聊天可读性,由其自身渲染,此处跳过。 * 沉浸式生成页(视频/图片)用 rich 大光球,秘钥管理(Token 列表)用 subtle。 */} {!isTextModel && ( )} {/* 内容区域 */}
{location.pathname.includes('image-generation') && ( )} {location.pathname.includes('video-generation') && ( )} {location.pathname.includes('text-model') && } {CLOUD_BRAIN_UI_ENABLED && isCloudBrain && } {location.pathname.includes('key-management') && }
{/* 移动端底部导航栏 */}
); }; export default ExperienceCenter;