8a48765a46
集中保留原版权声明,移除文件头检查和全局测试忽略规则。验证:全量单测、受影响用例复测及静态检查通过。
82 lines
2.2 KiB
React
82 lines
2.2 KiB
React
import React, { useState, useEffect } from 'react';
|
|
import { Tabs, TabPane } from '@/components/ui';
|
|
import { IconImage, IconVideo, IconBolt } from '@/components/ui/icons';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useLocation, useNavigate } from 'react-router-dom';
|
|
import ImageGenerationTab from './AICreation/ImageGenerationTab';
|
|
import VideoGenerationTab from './AICreation/VideoGenerationTab';
|
|
import VideoRemixTab from './AICreation/VideoRemixTab';
|
|
|
|
const AICreation = () => {
|
|
const { t } = useTranslation();
|
|
const location = useLocation();
|
|
const navigate = useNavigate();
|
|
const [activeTab, setActiveTab] = useState('image');
|
|
|
|
// 从URL中解析当前选中的标签页
|
|
useEffect(() => {
|
|
const pathSegments = location.pathname.split('/');
|
|
let tabKey = pathSegments[pathSegments.length - 1] || 'image';
|
|
if (tabKey === 'ai-creation') {
|
|
tabKey = 'image';
|
|
}
|
|
setActiveTab(tabKey);
|
|
}, [location.pathname]);
|
|
|
|
// 当标签页变化时,更新URL
|
|
const handleTabChange = (tabKey) => {
|
|
setActiveTab(tabKey);
|
|
navigate(`/experience-center/ai-creation/${tabKey}`);
|
|
};
|
|
|
|
return (
|
|
<div style={{ padding: '20px' }}>
|
|
<Tabs
|
|
activeKey={activeTab}
|
|
onChange={handleTabChange}
|
|
type='button'
|
|
size='large'
|
|
style={{ marginBottom: '24px' }}
|
|
>
|
|
<TabPane
|
|
tab={
|
|
<span>
|
|
<IconImage style={{ marginRight: '8px' }} />
|
|
{t('图片生成')}
|
|
</span>
|
|
}
|
|
itemKey='image'
|
|
>
|
|
<ImageGenerationTab />
|
|
</TabPane>
|
|
|
|
<TabPane
|
|
tab={
|
|
<span>
|
|
<IconVideo style={{ marginRight: '8px' }} />
|
|
{t('视频生成')}
|
|
</span>
|
|
}
|
|
itemKey='video'
|
|
>
|
|
<VideoGenerationTab />
|
|
</TabPane>
|
|
|
|
<TabPane
|
|
tab={
|
|
<span>
|
|
<IconBolt style={{ marginRight: '8px' }} />
|
|
{t('视频 Remix')}
|
|
</span>
|
|
}
|
|
itemKey='remix'
|
|
>
|
|
<VideoRemixTab />
|
|
</TabPane>
|
|
</Tabs>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default AICreation;
|