import { I18N_TECHNICAL_TEXT } from '../../i18n/technicalText.js';
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 { useMarquee } from '../../hooks/common/useMarquee';
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 { isCreationStudioEnabled } from '../../helpers/creationStudio';
import { badgeText } from '../../hooks/creation/creationWatch';
import {
useCreationUnread,
useCreationWatchPoller,
} from '../../hooks/creation/useCreationWatch';
import {
EXPERIENCE_MODULES,
useExperienceModules,
} from './useExperienceModules';
// 移动端底部导航组件(exp-mobile-bottom-nav:新创作台展开态期间由 creation-dock.css 隐藏)
const MobileBottomNav = ({ currentPath, navigate, isAvailable, unread }) => {
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',
unread: unread?.image || 0,
},
{
key: 'video',
configKey: 'videoGeneration',
icon: Video,
label: t('视频'),
path: '/experience-center/video-generation',
gradient: 'from-cyan-500 to-blue-600',
unread: unread?.video || 0,
},
].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 { visible: hasMarquee } = useMarquee();
// 新创作台:用户在体验中心其他页面时轻量轮询已提交的任务,完成后显示未读角标(WP C-4)
const creationStudioEnabled = isCreationStudioEnabled(statusState?.status);
useCreationWatchPoller(creationStudioEnabled);
const unread = useCreationUnread(creationStudioEnabled);
// 默认落地:进第一个对当前用户可用的子页;一个都没有时,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 ;
}
// 新创作台:视口高度用 dvh,微信 H5 / 移动端键盘弹起时底部创作台与生成按钮保持可见
const dynamicViewport =
(isVideoGeneration || isImageGeneration) && creationStudioEnabled;
// 云端大脑 / 图片生成 / 视频生成(非新创作台)与 /console/analytics 统一纯色页底:
// 读取 --uc-page-bg(浅色 #f8fafc,深色 --surface-bg-base),不叠加装饰光晕层
const consolePageBg =
isCloudBrain ||
((isVideoGeneration || isImageGeneration) && !creationStudioEnabled);
return (
{/* Sidebar - 桌面端 */}
{/* Main Content */}
{/* 统一页面背景层 —— 除 text-model 外,ExperienceCenter 是其子页面的唯一背景来源,
* 子组件不再各自渲染背景,避免双层叠加。
* text-model 特例:TextModel 自带 via-white 亮底保证聊天可读性,由其自身渲染,此处跳过。
* 沉浸式生成页(视频/图片)用 rich 大光球,密钥管理(Token 列表)用 subtle。 */}
{!isTextModel &&
!consolePageBg &&
(!(isVideoGeneration || isImageGeneration) ||
creationStudioEnabled) && (
)}
{/* 内容区域 */}
{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;