Initial import of weiyuan frontend
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Tabs, TabPane } from '@douyinfe/semi-ui';
|
||||
import { IconImage, IconVideo, IconBolt } from '@douyinfe/semi-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;
|
||||
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Modal, Typography, Tag } from '@douyinfe/semi-ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const ImageCompareModal = ({ visible, tasks, onClose }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
// 跟随窗口尺寸变化,保证 Modal 不会溢出视口
|
||||
const [viewportWidth, setViewportWidth] = useState(
|
||||
typeof window !== 'undefined' ? window.innerWidth : 1280,
|
||||
);
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') return;
|
||||
const onResize = () => setViewportWidth(window.innerWidth);
|
||||
window.addEventListener('resize', onResize);
|
||||
return () => window.removeEventListener('resize', onResize);
|
||||
}, []);
|
||||
|
||||
if (!visible || !tasks || tasks.length === 0) return null;
|
||||
|
||||
// 自适应列数:2 张并排,3 张 3 列,4 张 2×2
|
||||
const cols = tasks.length === 4 ? 2 : tasks.length;
|
||||
// 宽度 = 内容理想宽度,但不超过视口(留 48px 边距)和 1280 上限
|
||||
const ideal = 360 * cols + 64;
|
||||
const modalWidth = Math.min(1280, ideal, Math.max(320, viewportWidth - 48));
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('对比 {{n}} 张图片', { n: tasks.length })}
|
||||
visible={visible}
|
||||
onCancel={onClose}
|
||||
footer={null}
|
||||
width={modalWidth}
|
||||
bodyStyle={{ maxHeight: '80vh', overflow: 'auto', padding: 16 }}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: `repeat(${cols}, 1fr)`,
|
||||
gap: '16px',
|
||||
}}
|
||||
>
|
||||
{tasks.map((task) => (
|
||||
<div
|
||||
key={task.id}
|
||||
className='rounded-lg overflow-hidden border border-gray-200 dark:border-neutral-700 bg-white dark:bg-neutral-900'
|
||||
>
|
||||
<div className='aspect-square bg-gray-50 dark:bg-neutral-800 flex items-center justify-center overflow-hidden'>
|
||||
{task.imageUrl ? (
|
||||
<img
|
||||
src={task.imageUrl}
|
||||
alt=''
|
||||
className='w-full h-full object-contain'
|
||||
/>
|
||||
) : (
|
||||
<Text type='tertiary'>{t('无图片')}</Text>
|
||||
)}
|
||||
</div>
|
||||
<div className='p-3 space-y-2'>
|
||||
<div className='flex items-center gap-2 flex-wrap'>
|
||||
<Tag
|
||||
size='small'
|
||||
color='grey'
|
||||
className='!rounded !border-brand/25 !bg-brand/10 !text-brand-deep dark:!border-brand/25 dark:!bg-brand/15 dark:!text-brand-from'
|
||||
>
|
||||
{task.model || t('未知模型')}
|
||||
</Tag>
|
||||
<Tag size='small' color='grey' className='!rounded'>
|
||||
{task.width}×{task.height}
|
||||
</Tag>
|
||||
{task.quality && (
|
||||
<Tag size='small' color='grey' className='!rounded'>
|
||||
{task.quality}
|
||||
</Tag>
|
||||
)}
|
||||
</div>
|
||||
<Text
|
||||
size='small'
|
||||
className='block text-gray-600 dark:text-gray-300'
|
||||
style={{
|
||||
display: '-webkit-box',
|
||||
WebkitLineClamp: 4,
|
||||
WebkitBoxOrient: 'vertical',
|
||||
overflow: 'hidden',
|
||||
wordBreak: 'break-word',
|
||||
}}
|
||||
title={task.prompt}
|
||||
>
|
||||
{task.prompt || t('(无提示词)')}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ImageCompareModal;
|
||||
@@ -0,0 +1,335 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Modal,
|
||||
Image,
|
||||
Button,
|
||||
Space,
|
||||
Typography,
|
||||
Tag,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { Download, Copy, ImagePlus, Sparkles } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { showSuccess, showError } from '../../../../helpers';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const ImageDetailModal = ({
|
||||
visible,
|
||||
task,
|
||||
onClose,
|
||||
onReuseParams,
|
||||
onUseAsReference,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
// 跟随视口宽度,避免 900px 固定值在窄笔记本/平板上溢出
|
||||
const [viewportWidth, setViewportWidth] = useState(
|
||||
typeof window !== 'undefined' ? window.innerWidth : 900,
|
||||
);
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') return;
|
||||
const onResize = () => setViewportWidth(window.innerWidth);
|
||||
window.addEventListener('resize', onResize);
|
||||
return () => window.removeEventListener('resize', onResize);
|
||||
}, []);
|
||||
const modalWidth = Math.min(900, Math.max(320, viewportWidth - 48));
|
||||
|
||||
if (!task) return null;
|
||||
|
||||
const handleDownload = async () => {
|
||||
if (!task.imageUrl) {
|
||||
showError(t('图片不存在'));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await fetch(task.imageUrl);
|
||||
const blob = await response.blob();
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = `image_${task.id}.png`;
|
||||
link.style.display = 'none';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
requestAnimationFrame(() => {
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(url);
|
||||
});
|
||||
showSuccess(t('下载成功'));
|
||||
} catch (error) {
|
||||
console.error('下载失败:', error);
|
||||
window.open(task.imageUrl, '_blank');
|
||||
showSuccess(t('已在新窗口打开图片'));
|
||||
}
|
||||
};
|
||||
|
||||
// 复制(带 execCommand 兜底,兼容 http / 老浏览器)
|
||||
const copyToClipboard = async (text) => {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text);
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.warn('Clipboard API failed:', err);
|
||||
}
|
||||
}
|
||||
try {
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = text;
|
||||
textArea.style.position = 'fixed';
|
||||
textArea.style.left = '-9999px';
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
const ok = document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
return ok;
|
||||
} catch (err) {
|
||||
console.error('execCommand copy failed:', err);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleCopyPrompt = async () => {
|
||||
if (!task.prompt) return;
|
||||
const ok = await copyToClipboard(task.prompt);
|
||||
ok ? showSuccess(t('已复制到剪贴板')) : showError(t('复制失败'));
|
||||
};
|
||||
|
||||
const formatDateTime = (isoString) => {
|
||||
if (!isoString) return '-';
|
||||
const date = new Date(isoString);
|
||||
return date.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
});
|
||||
};
|
||||
|
||||
const isImageToImage = task.mode === 'image-to-image';
|
||||
|
||||
// 参数行:值为空就不显示
|
||||
const params = [
|
||||
{ label: t('模型'), value: task.model, color: 'grey', brand: true },
|
||||
{
|
||||
label: t('尺寸'),
|
||||
value: task.width && task.height ? `${task.width}×${task.height}` : null,
|
||||
color: 'grey',
|
||||
},
|
||||
{
|
||||
label: t('模式'),
|
||||
value: isImageToImage ? t('图生图') : t('文生图'),
|
||||
color: 'grey',
|
||||
},
|
||||
{ label: t('质量'), value: task.quality, color: 'grey' },
|
||||
{
|
||||
label: t('数量'),
|
||||
value: task.n && task.n > 1 ? `${task.n} ${t('张')}` : null,
|
||||
color: 'grey',
|
||||
},
|
||||
].filter((p) => p.value);
|
||||
|
||||
const handleReuseParamsClick = () => {
|
||||
if (onReuseParams) {
|
||||
onReuseParams(task);
|
||||
onClose();
|
||||
}
|
||||
};
|
||||
|
||||
const handleUseAsReferenceClick = () => {
|
||||
if (onUseAsReference) {
|
||||
onUseAsReference(task);
|
||||
onClose();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('图片详情')}
|
||||
visible={visible}
|
||||
onCancel={onClose}
|
||||
footer={
|
||||
// wrap 必须开:三个中文按钮(用作参考图/在此基础上微调/下载图片)合计 ~370px,
|
||||
// 而 modalWidth 是 viewportWidth-48,390px 屏上扣掉 content 的 padding 只剩 ~294px。
|
||||
// Space 默认 wrap:false + .semi-modal-content{overflow:hidden},
|
||||
// 溢出部分向左溢出并被裁掉 —— 「用作参考图」整个点不到。
|
||||
<Space wrap style={{ justifyContent: 'flex-end', width: '100%' }}>
|
||||
{onUseAsReference && task.imageUrl && (
|
||||
<Button
|
||||
icon={<ImagePlus size={16} />}
|
||||
onClick={handleUseAsReferenceClick}
|
||||
>
|
||||
{t('用作参考图')}
|
||||
</Button>
|
||||
)}
|
||||
{onReuseParams && (
|
||||
<Button
|
||||
icon={<Sparkles size={16} />}
|
||||
theme='light'
|
||||
type='primary'
|
||||
onClick={handleReuseParamsClick}
|
||||
>
|
||||
{t('在此基础上微调')}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
type='primary'
|
||||
icon={<Download size={16} />}
|
||||
onClick={handleDownload}
|
||||
disabled={!task.imageUrl}
|
||||
>
|
||||
{t('下载图片')}
|
||||
</Button>
|
||||
</Space>
|
||||
}
|
||||
width={modalWidth}
|
||||
bodyStyle={{
|
||||
maxHeight: '75vh',
|
||||
overflowX: 'hidden',
|
||||
overflowY: 'auto',
|
||||
padding: '20px 24px',
|
||||
}}
|
||||
>
|
||||
{/* 图片展示 */}
|
||||
<div className='text-center mb-5'>
|
||||
{isImageToImage && task.sourceImageUrl ? (
|
||||
<div className='flex gap-4 items-start justify-center'>
|
||||
<div className='flex-1' style={{ maxWidth: '48%' }}>
|
||||
<Text type='secondary' size='small' className='block mb-2'>
|
||||
{t('原图')}
|
||||
</Text>
|
||||
<Image
|
||||
src={task.sourceImageUrl}
|
||||
alt='Source'
|
||||
className='rounded-lg border border-gray-200 dark:border-neutral-700'
|
||||
style={{ maxWidth: '100%', maxHeight: 360 }}
|
||||
preview={{ src: task.sourceImageUrl }}
|
||||
/>
|
||||
</div>
|
||||
<div className='flex-1' style={{ maxWidth: '48%' }}>
|
||||
<Text type='secondary' size='small' className='block mb-2'>
|
||||
{t('生成图')}
|
||||
</Text>
|
||||
<Image
|
||||
src={task.imageUrl}
|
||||
alt='Generated'
|
||||
className='rounded-lg border border-gray-200 dark:border-neutral-700'
|
||||
style={{ maxWidth: '100%', maxHeight: 360 }}
|
||||
preview={{ src: task.imageUrl }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
) : task.imageUrl ? (
|
||||
<Image
|
||||
src={task.imageUrl}
|
||||
alt='Generated'
|
||||
className='rounded-lg border border-gray-200 dark:border-neutral-700'
|
||||
style={{ maxWidth: '100%', maxHeight: 520 }}
|
||||
preview={{ src: task.imageUrl }}
|
||||
/>
|
||||
) : (
|
||||
<div className='py-10 text-gray-400'>
|
||||
<Text type='tertiary'>{t('暂无图片')}</Text>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 参数 Tag 行 */}
|
||||
{params.length > 0 && (
|
||||
<div className='flex items-center gap-1.5 flex-wrap mb-4'>
|
||||
{params.map((p) => (
|
||||
<Tag
|
||||
key={p.label}
|
||||
color={p.color}
|
||||
size='small'
|
||||
className={`!rounded ${
|
||||
p.brand
|
||||
? '!border-brand/25 !bg-brand/10 !text-brand-deep dark:!border-brand/25 dark:!bg-brand/15 dark:!text-brand-from'
|
||||
: ''
|
||||
}`}
|
||||
>
|
||||
<span className='text-gray-500 mr-1'>{p.label}:</span>
|
||||
<strong>{p.value}</strong>
|
||||
</Tag>
|
||||
))}
|
||||
<Tag size='small' color='grey' className='!rounded'>
|
||||
<span className='text-gray-500 mr-1'>{t('创建')}:</span>
|
||||
<strong>{formatDateTime(task.createdAt)}</strong>
|
||||
</Tag>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 提示词 */}
|
||||
<div className='mb-3'>
|
||||
<div className='flex items-center justify-between mb-1.5'>
|
||||
<Text strong>{t('提示词')}</Text>
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
icon={<Copy size={14} />}
|
||||
onClick={handleCopyPrompt}
|
||||
className='!text-gray-500 hover:!text-brand-deep dark:hover:!text-brand-from'
|
||||
>
|
||||
{t('复制')}
|
||||
</Button>
|
||||
</div>
|
||||
<div
|
||||
className='p-3 rounded-lg bg-gray-50 dark:bg-neutral-800/60 text-sm leading-relaxed whitespace-pre-wrap break-words'
|
||||
style={{ minHeight: 60 }}
|
||||
>
|
||||
{task.prompt || <Text type='tertiary'>{t('(无提示词)')}</Text>}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 负向提示词(如果有) */}
|
||||
{task.negativePrompt && (
|
||||
<div className='mb-3'>
|
||||
<Text strong className='block mb-1.5'>
|
||||
{t('负向提示词')}
|
||||
</Text>
|
||||
<div className='p-3 rounded-lg bg-rose-50 dark:bg-rose-900/10 text-sm leading-relaxed whitespace-pre-wrap break-words'>
|
||||
{task.negativePrompt}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 失败信息 */}
|
||||
{task.status === 'failed' && task.errorMessage && (
|
||||
<div className='mb-3'>
|
||||
<Text
|
||||
strong
|
||||
className='block mb-1.5 text-rose-600 dark:text-rose-400'
|
||||
>
|
||||
{t('失败原因')}
|
||||
</Text>
|
||||
<div className='p-3 rounded-lg bg-rose-50 dark:bg-rose-900/10 text-xs text-rose-700 dark:text-rose-300 whitespace-pre-wrap break-words'>
|
||||
{task.errorMessage}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ImageDetailModal;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { useImageTaskManagement } from '../../../../hooks/image/useImageTaskManagement';
|
||||
import ImageGenerationForm from './ImageGenerationForm';
|
||||
import ImageTaskList from './ImageTaskList';
|
||||
import ImageDetailModal from './ImageDetailModal';
|
||||
|
||||
const ImageGenerationTab = () => {
|
||||
const {
|
||||
tasks,
|
||||
loading,
|
||||
addTask,
|
||||
deleteTask,
|
||||
retryTask,
|
||||
refreshTasks,
|
||||
refreshTaskUrl,
|
||||
} = useImageTaskManagement();
|
||||
|
||||
const [selectedTask, setSelectedTask] = useState(null);
|
||||
const [detailModalVisible, setDetailModalVisible] = useState(false);
|
||||
|
||||
// 历史卡片"复用参数":把任务参数回填到表单,但不立刻生成
|
||||
// 用对象引用变化触发 form 的 useEffect
|
||||
const [prefillSignal, setPrefillSignal] = useState(null);
|
||||
|
||||
// 处理生成提交
|
||||
const handleSubmit = (formData) => {
|
||||
addTask(formData);
|
||||
};
|
||||
|
||||
// 处理重新生成(直接再跑一次)
|
||||
const handleRegenerate = (taskData) => {
|
||||
addTask(taskData);
|
||||
};
|
||||
|
||||
// 处理"复用参数"(仅回填,等用户确认后再生成)
|
||||
const handleReuseParams = (task) => {
|
||||
setPrefillSignal({
|
||||
mode: task.mode,
|
||||
prompt: task.prompt,
|
||||
width: task.width,
|
||||
height: task.height,
|
||||
model: task.model,
|
||||
quality: task.quality,
|
||||
n: task.n,
|
||||
negativePrompt: task.negativePrompt,
|
||||
_ts: Date.now(),
|
||||
});
|
||||
};
|
||||
|
||||
// 处理"用作参考图"(生成结果 -> 切到图生图模式 + 自动回填参考图)
|
||||
// 不带 prompt:保留用户当前已输入的提示词,避免被空串覆盖。
|
||||
// 想要旧 prompt 一并回填的,请走"复用参数"。
|
||||
const handleUseAsReference = (task) => {
|
||||
if (!task?.imageUrl) return;
|
||||
setPrefillSignal({
|
||||
mode: 'image-to-image',
|
||||
referenceImageUrl: task.imageUrl,
|
||||
_ts: Date.now(),
|
||||
});
|
||||
};
|
||||
|
||||
// 空状态:用户点示例 prompt 卡片,直接填回 form
|
||||
const handleSamplePrompt = (samplePrompt) => {
|
||||
if (!samplePrompt) return;
|
||||
setPrefillSignal({
|
||||
mode: 'text-to-image',
|
||||
prompt: samplePrompt,
|
||||
_ts: Date.now(),
|
||||
});
|
||||
};
|
||||
|
||||
// 查看详情
|
||||
const handleViewDetail = (task) => {
|
||||
setSelectedTask(task);
|
||||
setDetailModalVisible(true);
|
||||
};
|
||||
|
||||
// 关闭详情
|
||||
const handleCloseDetail = () => {
|
||||
setDetailModalVisible(false);
|
||||
setSelectedTask(null);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{/*
|
||||
移动端(< md):Tab 整体允许竖向滚动 —— 表单和任务列表按自然高度堆叠,用户上下滚浏览。
|
||||
桌面端(>= md):保持 overflow-hidden,左右两栏各自内部滚动。
|
||||
*/}
|
||||
<div className='h-full min-h-0 flex flex-col md:flex-row gap-4 p-3 sm:p-4 overflow-y-auto md:overflow-hidden'>
|
||||
{/* 左侧:生成参数表单 */}
|
||||
<div className='w-full md:w-[22rem] xl:w-[24rem] md:flex-shrink-0 md:h-full'>
|
||||
<ImageGenerationForm
|
||||
onSubmit={handleSubmit}
|
||||
loading={loading}
|
||||
prefillSignal={prefillSignal}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 右侧:任务列表 —— flex-1 只在桌面端生效,移动端按内容高度展开 */}
|
||||
<div className='md:flex-1 md:min-h-0 flex flex-col'>
|
||||
<ImageTaskList
|
||||
tasks={tasks}
|
||||
onRefresh={refreshTasks}
|
||||
onRefreshUrl={refreshTaskUrl}
|
||||
onViewDetail={handleViewDetail}
|
||||
onDelete={deleteTask}
|
||||
onRetry={retryTask}
|
||||
onRegenerate={handleRegenerate}
|
||||
onReuseParams={handleReuseParams}
|
||||
onUseAsReference={handleUseAsReference}
|
||||
onSamplePrompt={handleSamplePrompt}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 图片详情模态框 */}
|
||||
<ImageDetailModal
|
||||
visible={detailModalVisible}
|
||||
task={selectedTask}
|
||||
onClose={handleCloseDetail}
|
||||
onReuseParams={handleReuseParams}
|
||||
onUseAsReference={handleUseAsReference}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default ImageGenerationTab;
|
||||
@@ -0,0 +1,290 @@
|
||||
# 图片生成任务列表界面优化说明
|
||||
|
||||
## 优化概览
|
||||
|
||||
本次优化重新设计了图片生成任务列表的界面,提升了用户体验和视觉美观度。
|
||||
|
||||
## 主要改进
|
||||
|
||||
### 1. 顶部操作栏设计
|
||||
|
||||
#### 统计卡片
|
||||
|
||||
- **三个统计卡片**:生成中、已完成、失败
|
||||
- **可点击筛选**:点击卡片可快速筛选对应状态的任务
|
||||
- **实时统计**:自动计算各状态任务数量
|
||||
- **高亮显示**:选中状态的卡片带蓝色边框
|
||||
|
||||
#### 搜索功能
|
||||
|
||||
- **实时搜索**:支持按提示词或模型搜索
|
||||
- **清除按钮**:可快速清空搜索关键词
|
||||
- **智能匹配**:不区分大小写的模糊搜索
|
||||
|
||||
#### 快捷操作
|
||||
|
||||
- **刷新按钮**:一键刷新所有任务
|
||||
- **清除筛选**:快速清除所有筛选条件
|
||||
|
||||
### 2. 任务卡片重新设计
|
||||
|
||||
#### 左侧图片预览区
|
||||
|
||||
**成功状态**:
|
||||
|
||||
- 显示生成的图片缩略图
|
||||
- 支持点击放大预览
|
||||
- 右上角显示图片尺寸标签
|
||||
- 半透明黑色背景,更有层次感
|
||||
|
||||
**进行中状态**:
|
||||
|
||||
- 显示加载动画(Spin)
|
||||
- 显示当前进度百分比
|
||||
- 渐变背景更美观
|
||||
|
||||
**失败状态**:
|
||||
|
||||
- 显示错误图标
|
||||
- 红色提示文字
|
||||
|
||||
#### 右侧内容区
|
||||
|
||||
- **状态标签**:带图标的彩色标签,更直观
|
||||
- **时间显示**:相对时间(刚刚、X分钟前等)
|
||||
- **提示词**:支持展开查看完整内容
|
||||
- **参数信息**:图片尺寸、使用模型
|
||||
- **进度条**:进行中任务显示实时进度
|
||||
- **错误提示**:失败任务显示错误原因
|
||||
|
||||
#### 操作按钮
|
||||
|
||||
**成功任务**:
|
||||
|
||||
- 查看:查看大图
|
||||
- 下载:直接下载图片(主要操作按钮)
|
||||
- 更多菜单:
|
||||
- 复制提示词
|
||||
- 复制图片链接
|
||||
- 删除任务
|
||||
|
||||
**失败任务**:
|
||||
|
||||
- 重试:重新生成
|
||||
- 删除:移除任务
|
||||
|
||||
**进行中任务**:
|
||||
|
||||
- 取消:停止生成
|
||||
|
||||
### 3. 视觉增强
|
||||
|
||||
#### 卡片效果
|
||||
|
||||
- **圆角设计**:12px圆角,更现代
|
||||
- **阴影效果**:轻微阴影增加层次感
|
||||
- **悬停动画**:鼠标悬停时卡片轻微上浮
|
||||
- **过渡效果**:所有交互都有流畅的过渡动画
|
||||
|
||||
#### 颜色系统
|
||||
|
||||
- **状态颜色**:
|
||||
- 生成中:蓝色 (blue)
|
||||
- 已完成:绿色 (green)
|
||||
- 失败:红色 (red)
|
||||
- **渐变背景**:顶部操作栏使用微妙的渐变
|
||||
- **统一风格**:遵循 Semi Design 设计规范
|
||||
|
||||
#### 响应式设计
|
||||
|
||||
- **移动端适配**:小屏幕下自动调整布局
|
||||
- **网格布局**:统计卡片自动适应屏幕宽度
|
||||
- **滚动优化**:自定义滚动条样式
|
||||
|
||||
### 4. 交互优化
|
||||
|
||||
#### 一键操作
|
||||
|
||||
- **下载图片**:点击下载按钮即可下载,无需右键
|
||||
- **复制功能**:一键复制提示词或图片链接
|
||||
- **快速筛选**:点击统计卡片快速切换筛选
|
||||
|
||||
#### 提示反馈
|
||||
|
||||
- **成功提示**:下载、复制成功后显示提示
|
||||
- **确认对话框**:删除操作需要确认
|
||||
- **错误处理**:操作失败时显示友好提示
|
||||
|
||||
#### 图片预览
|
||||
|
||||
- **点击预览**:点击缩略图查看大图
|
||||
- **原图显示**:支持查看原始尺寸
|
||||
- **缩放功能**:支持放大缩小
|
||||
|
||||
### 5. 性能优化
|
||||
|
||||
#### 计算优化
|
||||
|
||||
- **useMemo**:统计数据和筛选结果使用 memo 缓存
|
||||
- **按需渲染**:只渲染可见区域的任务
|
||||
- **虚拟滚动**:支持大量任务列表
|
||||
|
||||
#### 加载优化
|
||||
|
||||
- **懒加载**:图片懒加载减少初始加载时间
|
||||
- **增量更新**:只更新变化的任务
|
||||
- **缓存策略**:合理使用浏览器缓存
|
||||
|
||||
## 新增功能
|
||||
|
||||
### 1. 搜索和筛选
|
||||
|
||||
```javascript
|
||||
// 按状态筛选
|
||||
filterStatus: 'all' | 'processing' | 'success' | 'failed';
|
||||
|
||||
// 按关键词搜索
|
||||
searchKeyword: 提示词或模型名称;
|
||||
```
|
||||
|
||||
### 2. 批量操作
|
||||
|
||||
- 下载图片
|
||||
- 复制提示词
|
||||
- 复制图片链接
|
||||
- 删除任务
|
||||
|
||||
### 3. 统计功能
|
||||
|
||||
```javascript
|
||||
statistics: {
|
||||
total: 总任务数,
|
||||
processing: 生成中数量,
|
||||
success: 成功数量,
|
||||
failed: 失败数量
|
||||
}
|
||||
```
|
||||
|
||||
## 使用示例
|
||||
|
||||
### 基本用法
|
||||
|
||||
```jsx
|
||||
<ImageTaskList
|
||||
tasks={tasks} // 任务列表
|
||||
onRefresh={handleRefresh} // 刷新回调
|
||||
onViewDetail={handleViewDetail} // 查看详情回调
|
||||
onDelete={handleDelete} // 删除回调
|
||||
onRetry={handleRetry} // 重试回调
|
||||
/>
|
||||
```
|
||||
|
||||
### 任务数据结构
|
||||
|
||||
```javascript
|
||||
{
|
||||
id: '123', // 任务ID
|
||||
prompt: 'a beautiful sunset', // 提示词
|
||||
width: 1024, // 图片宽度
|
||||
height: 1024, // 图片高度
|
||||
model: 'sora_image', // 使用模型
|
||||
status: 'success', // 状态
|
||||
createdAt: '2025-11-29T...', // 创建时间
|
||||
imageUrl: 'https://...', // 图片URL
|
||||
progress: '100%', // 进度
|
||||
errorMessage: null // 错误信息
|
||||
}
|
||||
```
|
||||
|
||||
## 技术实现
|
||||
|
||||
### 组件结构
|
||||
|
||||
```
|
||||
ImageTaskList/
|
||||
├── ImageTaskList.jsx # 主组件
|
||||
├── ImageTaskList.css # 样式文件
|
||||
└── README.md # 说明文档
|
||||
```
|
||||
|
||||
### 依赖库
|
||||
|
||||
- **@douyinfe/semi-ui**:UI 组件库
|
||||
- **@douyinfe/semi-icons**:图标库
|
||||
- **react-i18next**:国际化
|
||||
- **React Hooks**:状态管理
|
||||
|
||||
### 核心 Hooks
|
||||
|
||||
```javascript
|
||||
useState; // 筛选和搜索状态
|
||||
useMemo; // 统计数据和筛选结果缓存
|
||||
useCallback; // 事件处理函数优化
|
||||
```
|
||||
|
||||
## 样式定制
|
||||
|
||||
### CSS 变量
|
||||
|
||||
```css
|
||||
--semi-color-primary // 主色
|
||||
--semi-color-success // 成功色
|
||||
--semi-color-warning // 警告色
|
||||
--semi-color-danger // 危险色
|
||||
--semi-color-bg-2 // 背景色
|
||||
--semi-color-border // 边框色
|
||||
```
|
||||
|
||||
### 自定义类
|
||||
|
||||
```css
|
||||
.task-card-hover // 卡片悬停效果
|
||||
.task-list-scroll // 滚动条样式
|
||||
.stat-card // 统计卡片样式
|
||||
.image-preview-container // 图片预览容器
|
||||
.progress-pulse // 进度条动画
|
||||
```
|
||||
|
||||
## 浏览器兼容性
|
||||
|
||||
- ✅ Chrome 90+
|
||||
- ✅ Firefox 88+
|
||||
- ✅ Safari 14+
|
||||
- ✅ Edge 90+
|
||||
- ✅ 移动端浏览器
|
||||
|
||||
## 已知问题
|
||||
|
||||
暂无
|
||||
|
||||
## 未来计划
|
||||
|
||||
### 短期
|
||||
|
||||
- [ ] 添加批量下载功能
|
||||
- [ ] 支持拖拽排序
|
||||
- [ ] 添加收藏功能
|
||||
|
||||
### 长期
|
||||
|
||||
- [ ] 添加标签分类
|
||||
- [ ] 支持导出历史记录
|
||||
- [ ] 添加分享功能
|
||||
- [ ] AI 推荐相似提示词
|
||||
|
||||
## 更新日志
|
||||
|
||||
### v2.0.0 (2025-11-29)
|
||||
|
||||
- ✨ 全新的界面设计
|
||||
- ✨ 添加搜索和筛选功能
|
||||
- ✨ 优化卡片布局和样式
|
||||
- ✨ 添加统计功能
|
||||
- ✨ 改进操作按钮
|
||||
- ✨ 添加图片预览
|
||||
- ✨ 优化移动端体验
|
||||
- 🐛 修复若干已知问题
|
||||
|
||||
## 反馈和建议
|
||||
|
||||
如有问题或建议,请联系开发团队。
|
||||
@@ -0,0 +1,220 @@
|
||||
/* 任务卡片悬停效果 */
|
||||
.task-card-hover {
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
.task-card-hover:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
|
||||
}
|
||||
|
||||
/* 滚动条样式已统一到 index.css 的 .app-scrollbar */
|
||||
|
||||
/* 统计卡片悬停效果 */
|
||||
.stat-card {
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.stat-card:hover {
|
||||
transform: scale(1.02);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
/* 图片预览悬停效果 */
|
||||
.image-preview-container {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.image-preview-container::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0);
|
||||
transition: background 0.3s;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.image-preview-container:hover::after {
|
||||
background: rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
/* 进度条动画 */
|
||||
@keyframes pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
/* 处理中状态左侧彩条流光 */
|
||||
@keyframes brandShimmer {
|
||||
0% {
|
||||
background-position: 0% 0%;
|
||||
}
|
||||
100% {
|
||||
background-position: 0% 200%;
|
||||
}
|
||||
}
|
||||
|
||||
/* drop target highlight */
|
||||
.image-ref-drop-active {
|
||||
outline: 2px dashed var(--brand-primary) !important;
|
||||
outline-offset: -4px;
|
||||
background: color-mix(
|
||||
in srgb,
|
||||
var(--brand-primary) 8%,
|
||||
transparent
|
||||
) !important;
|
||||
}
|
||||
|
||||
.progress-pulse {
|
||||
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
||||
}
|
||||
|
||||
/* 按钮组动画 */
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.action-buttons > * {
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.action-buttons > *:hover {
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
/* 空状态样式 */
|
||||
.empty-state {
|
||||
padding: 60px 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 搜索框样式增强 */
|
||||
.search-input-enhanced {
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.search-input-enhanced:focus-within {
|
||||
box-shadow: 0 0 0 2px rgba(var(--semi-color-primary-rgb), 0.2);
|
||||
}
|
||||
|
||||
/* 标签组样式 */
|
||||
.tag-group {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.task-card-content {
|
||||
flex-direction: column !important;
|
||||
}
|
||||
|
||||
.image-preview-container {
|
||||
width: 100% !important;
|
||||
min-height: 200px !important;
|
||||
}
|
||||
|
||||
.stat-cards-grid {
|
||||
grid-template-columns: 1fr !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* Badge 样式覆盖 - 修复默认蓝色圆形背景 */
|
||||
.image-task-list .semi-badge-primary.semi-badge-solid .semi-badge-count,
|
||||
.image-task-list
|
||||
.semi-badge-primary.semi-badge-solid.semi-badge-block
|
||||
.semi-badge-count {
|
||||
background: transparent !important;
|
||||
background-image: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
/* 历史标题区域的 Badge 特定样式 */
|
||||
.image-task-list .semi-badge.semi-badge-primary .semi-badge-count {
|
||||
background: linear-gradient(
|
||||
to right,
|
||||
var(--brand-gradient-from),
|
||||
var(--brand-gradient-to)
|
||||
) !important;
|
||||
border: none !important;
|
||||
box-shadow: 0 2px 8px
|
||||
color-mix(in srgb, var(--brand-primary) 30%, transparent) !important;
|
||||
}
|
||||
|
||||
/* 图片生成页局部控件留白:避免搜索/筛选内容贴住玻璃卡片边框 */
|
||||
.image-task-list .image-task-search.semi-input-wrapper {
|
||||
padding-left: 10px !important;
|
||||
padding-right: 8px !important;
|
||||
border: 1px solid rgb(255 255 255 / 0.5) !important;
|
||||
background: rgb(255 255 255 / 0.48) !important;
|
||||
backdrop-filter: blur(14px);
|
||||
}
|
||||
|
||||
.dark .image-task-list .image-task-search.semi-input-wrapper {
|
||||
border-color: rgb(255 255 255 / 0.1) !important;
|
||||
background: rgb(255 255 255 / 0.06) !important;
|
||||
}
|
||||
|
||||
.image-task-list .image-task-search .semi-input-prefix {
|
||||
margin-right: 6px !important;
|
||||
}
|
||||
|
||||
.image-task-list .image-task-search .semi-input {
|
||||
padding-left: 2px !important;
|
||||
}
|
||||
|
||||
.image-task-list .image-task-filter-select.semi-select {
|
||||
padding-left: 8px !important;
|
||||
border: 1px solid rgb(255 255 255 / 0.5) !important;
|
||||
background: rgb(255 255 255 / 0.48) !important;
|
||||
backdrop-filter: blur(14px);
|
||||
}
|
||||
|
||||
.dark .image-task-list .image-task-filter-select.semi-select {
|
||||
border-color: rgb(255 255 255 / 0.1) !important;
|
||||
background: rgb(255 255 255 / 0.06) !important;
|
||||
}
|
||||
|
||||
.image-task-list .image-task-filter-select .semi-select-selection {
|
||||
padding-left: 2px !important;
|
||||
}
|
||||
|
||||
.image-task-list .image-task-group-header {
|
||||
margin-left: -4px;
|
||||
margin-right: -4px;
|
||||
border: 1px solid rgb(255 255 255 / 0.45);
|
||||
border-radius: 14px;
|
||||
box-shadow: 0 10px 26px rgb(15 23 42 / 0.06);
|
||||
}
|
||||
|
||||
.dark .image-task-list .image-task-group-header {
|
||||
border-color: rgb(255 255 255 / 0.1);
|
||||
box-shadow: 0 10px 26px rgb(0 0 0 / 0.24);
|
||||
}
|
||||
|
||||
/* ===== 触屏命中区兜底 ===== */
|
||||
/* 卡片操作按钮统一 height:24px(Semi size='small'),在触屏上低于 32px 的下限,
|
||||
且十几个按钮彼此相邻、又叠在图片上,误触率很高。
|
||||
这里不改视觉高度(改了会撑破密集网格),只用伪元素把可点区域向外扩到 32px。 */
|
||||
@media (hover: none) {
|
||||
.image-task-card .semi-button {
|
||||
position: relative;
|
||||
}
|
||||
.image-task-card .semi-button::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: -5px -3px;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,389 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
Empty,
|
||||
Input,
|
||||
Modal,
|
||||
Progress,
|
||||
Radio,
|
||||
Spin,
|
||||
Tag,
|
||||
Tooltip,
|
||||
Upload,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import {
|
||||
Check,
|
||||
ExternalLink,
|
||||
Image as ImageIcon,
|
||||
Plus,
|
||||
ShieldCheck,
|
||||
Trash2,
|
||||
UserRound,
|
||||
} from 'lucide-react';
|
||||
import { QRCodeSVG } from 'qrcode.react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { showError, showSuccess } from '../../../../../helpers';
|
||||
import { usePortraitAssets } from '../../../../../hooks/video/usePortraitAssets';
|
||||
|
||||
const statusColor = {
|
||||
active: 'green',
|
||||
draft: 'grey',
|
||||
processing: 'blue',
|
||||
failed: 'red',
|
||||
};
|
||||
|
||||
const PortraitAssetPicker = ({
|
||||
onSelect,
|
||||
selectedAssetId,
|
||||
onClearSelection,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [name, setName] = useState('');
|
||||
const [consent, setConsent] = useState(false);
|
||||
const [selectedPortraitId, setSelectedPortraitId] = useState('');
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [secondsLeft, setSecondsLeft] = useState(0);
|
||||
const portrait = usePortraitAssets(visible);
|
||||
|
||||
const selectedPortrait = useMemo(
|
||||
() =>
|
||||
portrait.portraits.find((item) => item.id === selectedPortraitId) || null,
|
||||
[portrait.portraits, selectedPortraitId],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedPortraitId && portrait.portraits.length > 0) {
|
||||
setSelectedPortraitId(portrait.portraits[0].id);
|
||||
}
|
||||
}, [portrait.portraits, selectedPortraitId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!portrait.session?.expires_at) {
|
||||
setSecondsLeft(0);
|
||||
return undefined;
|
||||
}
|
||||
const tick = () => {
|
||||
setSecondsLeft(
|
||||
Math.max(
|
||||
0,
|
||||
portrait.session.expires_at - Math.floor(Date.now() / 1000),
|
||||
),
|
||||
);
|
||||
};
|
||||
tick();
|
||||
const timer = setInterval(tick, 1000);
|
||||
return () => clearInterval(timer);
|
||||
}, [portrait.session?.expires_at]);
|
||||
|
||||
const handleCreate = async () => {
|
||||
if (!name.trim() || !consent) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
const created = await portrait.createPortrait(name.trim());
|
||||
setSelectedPortraitId(created.id);
|
||||
setName('');
|
||||
setConsent(false);
|
||||
} catch (error) {
|
||||
showError(portrait.errorMessage(error));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleVerify = async () => {
|
||||
if (!selectedPortraitId) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
await portrait.startVerification(selectedPortraitId);
|
||||
} catch (error) {
|
||||
showError(portrait.errorMessage(error));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleUpload = async ({ fileList }) => {
|
||||
const file = fileList?.[fileList.length - 1]?.fileInstance;
|
||||
if (!file || !selectedPortraitId) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
const asset = await portrait.uploadPortraitAsset(
|
||||
selectedPortraitId,
|
||||
file,
|
||||
);
|
||||
showSuccess(t('素材已提交审核'));
|
||||
portrait.refreshAssetUntilTerminal(asset.id).catch(() => {});
|
||||
} catch (error) {
|
||||
showError(portrait.errorMessage(error));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
const assets = portrait.assets.filter(
|
||||
(asset) => asset.portrait_id === selectedPortraitId,
|
||||
);
|
||||
|
||||
const confirmDeleteAsset = (asset) => {
|
||||
Modal.confirm({
|
||||
title: t('删除素材'),
|
||||
content: t('删除后将无法继续用于视频生成。'),
|
||||
okType: 'danger',
|
||||
onOk: async () => {
|
||||
try {
|
||||
await portrait.deleteAsset(asset.id);
|
||||
if (asset.id === selectedAssetId) onClearSelection?.();
|
||||
} catch (error) {
|
||||
showError(portrait.errorMessage(error));
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const confirmDeletePortrait = (item) => {
|
||||
Modal.confirm({
|
||||
title: t('删除人像'),
|
||||
content: t('该人像及其全部关联素材将被删除。'),
|
||||
okType: 'danger',
|
||||
onOk: async () => {
|
||||
try {
|
||||
const clearsSelection = portrait.assets.some(
|
||||
(asset) =>
|
||||
asset.id === selectedAssetId && asset.portrait_id === item.id,
|
||||
);
|
||||
await portrait.deletePortrait(item.id);
|
||||
if (clearsSelection) onClearSelection?.();
|
||||
if (selectedPortraitId === item.id) setSelectedPortraitId('');
|
||||
showSuccess(t('人像已删除'));
|
||||
} catch (error) {
|
||||
showError(portrait.errorMessage(error));
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
icon={<UserRound size={16} />}
|
||||
theme='light'
|
||||
onClick={() => setVisible(true)}
|
||||
>
|
||||
{t('真人人像素材')}
|
||||
</Button>
|
||||
<Modal
|
||||
title={t('真人人像素材')}
|
||||
visible={visible}
|
||||
onCancel={() => setVisible(false)}
|
||||
footer={null}
|
||||
width={720}
|
||||
bodyStyle={{ maxHeight: '72vh', overflow: 'auto' }}
|
||||
>
|
||||
{portrait.loading ? (
|
||||
<div className='flex justify-center py-12'>
|
||||
<Spin />
|
||||
</div>
|
||||
) : portrait.enabled === false ? (
|
||||
<Empty title={t('真人人像素材未启用')} />
|
||||
) : (
|
||||
<div className='flex flex-col gap-5'>
|
||||
<div className='flex flex-col gap-3 border-b border-solid border-semi-color-border pb-5'>
|
||||
<div className='flex gap-2'>
|
||||
<Input
|
||||
value={name}
|
||||
onChange={setName}
|
||||
maxLength={128}
|
||||
placeholder={t('人像名称')}
|
||||
/>
|
||||
<Tooltip content={t('创建人像')}>
|
||||
<Button
|
||||
icon={<Plus size={16} />}
|
||||
onClick={handleCreate}
|
||||
loading={busy}
|
||||
disabled={!name.trim() || !consent}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<Checkbox
|
||||
checked={consent}
|
||||
onChange={(event) => setConsent(event.target.checked)}
|
||||
>
|
||||
{t('我已获得本人授权并拥有该人像素材的合法使用权')}
|
||||
</Checkbox>
|
||||
</div>
|
||||
|
||||
{portrait.portraits.length > 0 && (
|
||||
<Radio.Group
|
||||
value={selectedPortraitId}
|
||||
onChange={(event) => {
|
||||
setSelectedPortraitId(event.target.value);
|
||||
portrait.setSession(null);
|
||||
}}
|
||||
direction='vertical'
|
||||
className='w-full'
|
||||
>
|
||||
{portrait.portraits.map((item) => (
|
||||
<div key={item.id} className='flex items-center gap-2'>
|
||||
<Radio value={item.id} className='min-w-0 flex-1'>
|
||||
<span className='inline-flex min-w-0 items-center gap-2 py-1'>
|
||||
<span className='truncate'>{item.name}</span>
|
||||
<Tag
|
||||
color={statusColor[item.status] || 'grey'}
|
||||
size='small'
|
||||
>
|
||||
{item.status}
|
||||
</Tag>
|
||||
<span className='text-xs text-semi-color-text-2'>
|
||||
{item.id.slice(-6)}
|
||||
</span>
|
||||
</span>
|
||||
</Radio>
|
||||
<Tooltip content={t('删除人像')}>
|
||||
<Button
|
||||
type='danger'
|
||||
theme='borderless'
|
||||
icon={<Trash2 size={16} />}
|
||||
onClick={() => confirmDeletePortrait(item)}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
))}
|
||||
</Radio.Group>
|
||||
)}
|
||||
|
||||
{selectedPortrait &&
|
||||
selectedPortrait.status !== 'active' &&
|
||||
!portrait.session && (
|
||||
<Button
|
||||
icon={<ShieldCheck size={16} />}
|
||||
onClick={handleVerify}
|
||||
loading={busy}
|
||||
>
|
||||
{t('开始活体认证')}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{portrait.session &&
|
||||
['pending', 'confirming'].includes(portrait.session.status) && (
|
||||
<div className='flex flex-col items-center gap-3 border-y border-solid border-semi-color-border py-5'>
|
||||
<QRCodeSVG value={portrait.session.h5_url} size={184} />
|
||||
<Progress
|
||||
percent={Math.round((secondsLeft / 120) * 100)}
|
||||
showInfo
|
||||
format={() => `${secondsLeft}s`}
|
||||
style={{ width: 240 }}
|
||||
/>
|
||||
<Button
|
||||
icon={<ExternalLink size={16} />}
|
||||
onClick={() =>
|
||||
window.open(
|
||||
portrait.session.h5_url,
|
||||
'_blank',
|
||||
'noopener,noreferrer',
|
||||
)
|
||||
}
|
||||
>
|
||||
{t('打开认证页面')}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{portrait.session?.status === 'succeeded' && (
|
||||
<Tag color='green' prefixIcon={<Check size={14} />}>
|
||||
{t('认证通过')}
|
||||
</Tag>
|
||||
)}
|
||||
|
||||
{selectedPortrait?.status === 'active' && (
|
||||
<Upload
|
||||
accept='image/*'
|
||||
limit={1}
|
||||
uploadTrigger='custom'
|
||||
showUploadList={false}
|
||||
onChange={handleUpload}
|
||||
>
|
||||
<Button icon={<ImageIcon size={16} />} loading={busy}>
|
||||
{t('上传真人素材')}
|
||||
</Button>
|
||||
</Upload>
|
||||
)}
|
||||
|
||||
<div className='flex flex-col divide-y divide-semi-color-border'>
|
||||
{assets.map((asset) => (
|
||||
<div
|
||||
key={asset.id}
|
||||
className='flex min-h-[64px] items-center gap-3 py-3'
|
||||
>
|
||||
<div className='h-12 w-12 shrink-0 overflow-hidden rounded-[6px] bg-semi-color-fill-0'>
|
||||
{asset.preview_url && (
|
||||
<img
|
||||
src={asset.preview_url}
|
||||
alt={asset.name}
|
||||
className='h-full w-full object-cover'
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className='min-w-0 flex-1'>
|
||||
<div className='truncate text-sm font-medium'>
|
||||
{asset.name}
|
||||
</div>
|
||||
<Tag
|
||||
color={statusColor[asset.status] || 'grey'}
|
||||
size='small'
|
||||
>
|
||||
{asset.status}
|
||||
</Tag>
|
||||
</div>
|
||||
{asset.status === 'active' && (
|
||||
<Tooltip content={t('选择素材')}>
|
||||
<Button
|
||||
icon={<Check size={16} />}
|
||||
onClick={() => {
|
||||
onSelect(asset);
|
||||
setVisible(false);
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
)}
|
||||
<Tooltip content={t('删除素材')}>
|
||||
<Button
|
||||
type='danger'
|
||||
theme='borderless'
|
||||
icon={<Trash2 size={16} />}
|
||||
onClick={() => confirmDeleteAsset(asset)}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default PortraitAssetPicker;
|
||||
@@ -0,0 +1,944 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
Card,
|
||||
TextArea,
|
||||
Upload,
|
||||
Collapse,
|
||||
Select,
|
||||
InputNumber,
|
||||
Switch,
|
||||
Button,
|
||||
Tag,
|
||||
Typography,
|
||||
Tooltip,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import {
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
Image as ImageIcon,
|
||||
Video,
|
||||
Info,
|
||||
CreditCard,
|
||||
X,
|
||||
Film,
|
||||
Wand2,
|
||||
Layers,
|
||||
Settings2,
|
||||
Clock,
|
||||
Maximize,
|
||||
Mic,
|
||||
Sparkles,
|
||||
} from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { PROMPT_TEMPLATES } from '../../../../../constants/video-generation.constant';
|
||||
import ModelSelector from '../../../../../components/common/ModelSelector';
|
||||
import { MODEL_CATEGORY } from '../../../../../constants';
|
||||
import { convertUSDToCurrency } from '../../../../../helpers';
|
||||
import PortraitAssetPicker from './PortraitAssetPicker';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
// 判断是否是阿里云模型(支持高级参数)
|
||||
const isAlibabaModel = (model) => {
|
||||
if (!model) return false;
|
||||
|
||||
// 检查 vendor 字段
|
||||
const vendor =
|
||||
typeof model === 'object' ? model.vendor || model.provider || '' : '';
|
||||
|
||||
// 检查模型名称
|
||||
const modelName =
|
||||
typeof model === 'object' ? model.model_name || model.id || '' : model;
|
||||
|
||||
// 阿里云厂商名称匹配
|
||||
const aliVendors = ['阿里云', '阿里', 'alibaba', 'aliyun', 'dashscope'];
|
||||
const isAliVendor = aliVendors.some((v) =>
|
||||
vendor.toLowerCase().includes(v.toLowerCase()),
|
||||
);
|
||||
|
||||
// 阿里云模型名称特征
|
||||
const aliModelPrefixes = ['wan', 'wanx', 'qwen'];
|
||||
const isAliModel = aliModelPrefixes.some((prefix) =>
|
||||
modelName.toLowerCase().startsWith(prefix),
|
||||
);
|
||||
|
||||
return isAliVendor || isAliModel;
|
||||
};
|
||||
|
||||
const VideoInputPanel = ({
|
||||
formData,
|
||||
setFormData,
|
||||
onCollapse,
|
||||
collapsed,
|
||||
selectedModel,
|
||||
setSelectedModel,
|
||||
modelInfo,
|
||||
collapsible = true,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
// 检查当前模型是否支持高级参数
|
||||
const showAdvancedParams = isAlibabaModel(selectedModel);
|
||||
|
||||
const hoverScale = (e) => {
|
||||
e.currentTarget.style.transform = 'scale(1.1)';
|
||||
};
|
||||
|
||||
const resetScale = (e) => {
|
||||
e.currentTarget.style.transform = 'scale(1)';
|
||||
};
|
||||
|
||||
// 根据模式动态获取模型分类
|
||||
const getModelCategory = () => {
|
||||
return formData.mode === 'text2video'
|
||||
? MODEL_CATEGORY.TEXT_TO_VIDEO
|
||||
: MODEL_CATEGORY.IMAGE_TO_VIDEO;
|
||||
};
|
||||
|
||||
// 更新表单字段
|
||||
const updateField = (field, value) => {
|
||||
setFormData((prev) => ({ ...prev, [field]: value }));
|
||||
};
|
||||
|
||||
// 选择模板
|
||||
const handleTemplateSelect = (value) => {
|
||||
updateField('selectedTemplate', value);
|
||||
};
|
||||
|
||||
// 图片上传处理
|
||||
const handleImageUpload = (info) => {
|
||||
const { fileList } = info;
|
||||
if (fileList && fileList.length > 0) {
|
||||
const file = fileList[fileList.length - 1];
|
||||
const fileInstance = file.fileInstance;
|
||||
if (fileInstance) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
image: e.target.result,
|
||||
imagePreview: e.target.result,
|
||||
imageFile: fileInstance,
|
||||
imageName: fileInstance.name,
|
||||
imageIdentityType: 'aigc',
|
||||
}));
|
||||
};
|
||||
reader.readAsDataURL(fileInstance);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 移除图片
|
||||
const handleImageRemove = () => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
image: null,
|
||||
imagePreview: null,
|
||||
imageFile: null,
|
||||
imageName: null,
|
||||
imageIdentityType: null,
|
||||
}));
|
||||
};
|
||||
|
||||
const handlePortraitAssetSelect = (asset) => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
image: `asset://${asset.id}`,
|
||||
imagePreview: asset.preview_url || null,
|
||||
imageFile: null,
|
||||
imageName: asset.name,
|
||||
imageIdentityType: 'real_person',
|
||||
}));
|
||||
};
|
||||
|
||||
// 单列(手机)布局不提供折叠:没有相邻面板可以让位,收起只会留下一片空白,
|
||||
// 而唯一的恢复入口是一个浮在屏幕左侧垂直中央的裸箭头。
|
||||
if (collapsed && collapsible) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: 'fixed',
|
||||
left: 0,
|
||||
top: '50%',
|
||||
transform: 'translateY(-50%)',
|
||||
zIndex: 100,
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
icon={<ChevronRight size={20} />}
|
||||
onClick={onCollapse}
|
||||
style={{
|
||||
borderTopLeftRadius: 0,
|
||||
borderBottomLeftRadius: 0,
|
||||
color: '#1890ff',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='relative h-full overflow-auto' style={{ padding: '16px' }}>
|
||||
{/* 背景装饰 —— 走 bg-glow-* 两 stop(from/to) */}
|
||||
<div className='absolute inset-0 pointer-events-none opacity-30'>
|
||||
<div className='absolute top-10 right-0 w-32 h-32 bg-gradient-to-br from-bg-glow-from/20 to-bg-glow-to/20 rounded-full blur-3xl' />
|
||||
<div className='absolute bottom-20 left-0 w-40 h-40 bg-gradient-to-br from-bg-glow-from/20 to-bg-glow-to/20 rounded-full blur-3xl' />
|
||||
</div>
|
||||
|
||||
{/* 收起按钮 —— 仅在左右分栏布局下提供 */}
|
||||
{collapsible && (
|
||||
<div style={{ marginBottom: '16px', textAlign: 'right' }}>
|
||||
<Button
|
||||
icon={<ChevronLeft size={18} />}
|
||||
onClick={onCollapse}
|
||||
size='small'
|
||||
type='tertiary'
|
||||
className='hover:bg-cyan-50 dark:hover:bg-cyan-900/30 transition-colors'
|
||||
style={{ color: '#06b6d4' }}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 生成方式 */}
|
||||
<div className='relative mb-4'>
|
||||
<div className='absolute -inset-0.5 bg-gradient-to-r from-cyan-400/20 to-blue-400/20 rounded-[14px] blur-sm' />
|
||||
<Card
|
||||
title={
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
||||
<div className='p-1.5 bg-gradient-to-br from-cyan-500 to-blue-600 rounded-lg'>
|
||||
<Layers size={14} className='text-white' />
|
||||
</div>
|
||||
<span className='font-semibold bg-clip-text text-transparent bg-gradient-to-r from-cyan-600 to-blue-600 dark:from-cyan-400 dark:to-blue-400'>
|
||||
{t('生成方式')}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
className='relative bg-white/90 dark:bg-neutral-900/90 backdrop-blur-sm'
|
||||
style={{
|
||||
borderRadius: '12px',
|
||||
boxShadow: '0 4px 16px rgba(6, 182, 212, 0.08)',
|
||||
border: 'none',
|
||||
}}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
headerStyle={{ padding: '12px 16px' }}
|
||||
>
|
||||
<div style={{ display: 'flex', gap: '12px' }}>
|
||||
<div
|
||||
onClick={() => updateField('mode', 'text2video')}
|
||||
onMouseEnter={hoverScale}
|
||||
onMouseLeave={resetScale}
|
||||
className={`group relative overflow-hidden ${formData.mode === 'text2video' ? 'ring-2 ring-cyan-500 shadow-lg shadow-cyan-500/20' : 'border border-gray-200 dark:border-neutral-700'}`}
|
||||
style={{
|
||||
flex: 1,
|
||||
padding: '16px',
|
||||
borderRadius: '12px',
|
||||
cursor: 'pointer',
|
||||
backgroundColor:
|
||||
formData.mode === 'text2video'
|
||||
? 'rgba(6, 182, 212, 0.05)'
|
||||
: 'transparent',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
gap: '8px',
|
||||
transition: 'all 0.3s ease',
|
||||
}}
|
||||
>
|
||||
{formData.mode === 'text2video' && (
|
||||
<div className='absolute inset-0 bg-gradient-to-br from-cyan-500/10 to-blue-500/10' />
|
||||
)}
|
||||
<div
|
||||
className={`relative p-2.5 rounded-xl transition-all ${formData.mode === 'text2video' ? 'bg-gradient-to-br from-cyan-500 to-blue-600 shadow-lg' : 'bg-gray-100 dark:bg-neutral-800'}`}
|
||||
>
|
||||
<Film
|
||||
size={24}
|
||||
className={
|
||||
formData.mode === 'text2video'
|
||||
? 'text-white'
|
||||
: 'text-gray-500 dark:text-gray-400'
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<span
|
||||
className={`relative text-sm font-medium ${formData.mode === 'text2video' ? 'text-cyan-600 dark:text-cyan-400' : 'text-gray-600 dark:text-gray-400'}`}
|
||||
>
|
||||
{t('文生视频')}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
onClick={() => updateField('mode', 'image2video')}
|
||||
onMouseEnter={hoverScale}
|
||||
onMouseLeave={resetScale}
|
||||
className={`group relative overflow-hidden ${formData.mode === 'image2video' ? 'ring-2 ring-blue-500 shadow-lg shadow-blue-500/20' : 'border border-gray-200 dark:border-neutral-700'}`}
|
||||
style={{
|
||||
flex: 1,
|
||||
padding: '16px',
|
||||
borderRadius: '12px',
|
||||
cursor: 'pointer',
|
||||
backgroundColor:
|
||||
formData.mode === 'image2video'
|
||||
? 'rgba(59, 130, 246, 0.05)'
|
||||
: 'transparent',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
gap: '8px',
|
||||
transition: 'all 0.3s ease',
|
||||
}}
|
||||
>
|
||||
{formData.mode === 'image2video' && (
|
||||
<div className='absolute inset-0 bg-gradient-to-br from-blue-500/10 to-brand-to/10' />
|
||||
)}
|
||||
<div
|
||||
className={`relative p-2.5 rounded-xl transition-all ${formData.mode === 'image2video' ? 'bg-gradient-to-br from-blue-500 to-brand-to shadow-lg' : 'bg-gray-100 dark:bg-neutral-800'}`}
|
||||
>
|
||||
<ImageIcon
|
||||
size={24}
|
||||
className={
|
||||
formData.mode === 'image2video'
|
||||
? 'text-white'
|
||||
: 'text-gray-500 dark:text-gray-400'
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<span
|
||||
className={`relative text-sm font-medium ${formData.mode === 'image2video' ? 'text-blue-600 dark:text-blue-400' : 'text-gray-600 dark:text-gray-400'}`}
|
||||
>
|
||||
{t('图生视频')}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* 模型选择 */}
|
||||
<div className='relative mb-4'>
|
||||
<div className='absolute -inset-0.5 bg-gradient-to-r from-brand-from/20 to-brand-to/20 rounded-[14px] blur-sm' />
|
||||
<Card
|
||||
title={
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
||||
<div className='p-1.5 bg-gradient-to-br from-brand-from to-brand-to rounded-lg'>
|
||||
<Wand2 size={14} className='text-white' />
|
||||
</div>
|
||||
<span className='font-semibold bg-clip-text text-transparent bg-gradient-to-r from-brand-from to-brand-to dark:from-brand-from dark:to-brand-to'>
|
||||
{t('选择模型')}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
className='relative bg-white/90 dark:bg-neutral-900/90 backdrop-blur-sm'
|
||||
style={{
|
||||
borderRadius: '12px',
|
||||
boxShadow:
|
||||
'0 4px 16px color-mix(in srgb, var(--brand-gradient-via) 8%, transparent)',
|
||||
border: 'none',
|
||||
}}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
headerStyle={{ padding: '12px 16px' }}
|
||||
>
|
||||
<ModelSelector
|
||||
key={formData.mode}
|
||||
category={getModelCategory()}
|
||||
value={
|
||||
selectedModel?.id || selectedModel?.model_name || selectedModel
|
||||
}
|
||||
onChange={(model) => {
|
||||
setSelectedModel(model);
|
||||
}}
|
||||
placeholder={t('请选择模型')}
|
||||
/>
|
||||
{/* 模型信息简要展示 */}
|
||||
{modelInfo && (
|
||||
<div
|
||||
style={{
|
||||
marginTop: '12px',
|
||||
padding: '12px',
|
||||
backgroundColor: 'var(--semi-color-fill-0)',
|
||||
borderRadius: '8px',
|
||||
fontSize: '13px',
|
||||
border: '1px solid var(--semi-color-border)',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<Text type='tertiary'>{t('厂商')}</Text>
|
||||
<Tag size='small' color='blue'>
|
||||
{modelInfo.provider}
|
||||
</Tag>
|
||||
</div>
|
||||
{Number(modelInfo.price) > 0 && (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
marginTop: '8px',
|
||||
}}
|
||||
>
|
||||
<Text
|
||||
type='tertiary'
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '4px',
|
||||
}}
|
||||
>
|
||||
<CreditCard size={14} />
|
||||
{t('单价')}
|
||||
</Text>
|
||||
<Text strong style={{ color: 'var(--semi-color-danger)' }}>
|
||||
{convertUSDToCurrency(Number(modelInfo.price || 0), 6)}
|
||||
</Text>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* 场景模板 */}
|
||||
<div className='relative mb-4'>
|
||||
<div className='absolute -inset-0.5 bg-gradient-to-r from-amber-400/20 to-orange-400/20 rounded-[14px] blur-sm' />
|
||||
<Card
|
||||
title={
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
||||
<div className='p-1.5 bg-gradient-to-br from-amber-500 to-orange-500 rounded-lg'>
|
||||
<Sparkles size={14} className='text-white' />
|
||||
</div>
|
||||
<span className='font-semibold bg-clip-text text-transparent bg-gradient-to-r from-amber-600 to-orange-600 dark:from-amber-400 dark:to-orange-400'>
|
||||
{t('场景模板')}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
className='relative bg-white/90 dark:bg-neutral-900/90 backdrop-blur-sm'
|
||||
style={{
|
||||
borderRadius: '12px',
|
||||
boxShadow: '0 4px 16px rgba(251, 146, 60, 0.08)',
|
||||
border: 'none',
|
||||
}}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
headerStyle={{ padding: '12px 16px' }}
|
||||
>
|
||||
<Select
|
||||
placeholder={t('选择场景模板(可选)')}
|
||||
value={formData.selectedTemplate}
|
||||
onChange={handleTemplateSelect}
|
||||
style={{ width: '100%' }}
|
||||
showClear
|
||||
>
|
||||
{PROMPT_TEMPLATES.map((template, index) => (
|
||||
<Select.Option key={index} value={template.prompt}>
|
||||
{template.label}
|
||||
</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
{formData.selectedTemplate && (
|
||||
<div
|
||||
style={{
|
||||
marginTop: '12px',
|
||||
padding: '12px',
|
||||
backgroundColor: 'var(--semi-color-fill-0)',
|
||||
borderRadius: '8px',
|
||||
border: '1px solid var(--semi-color-border)',
|
||||
}}
|
||||
>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('模板内容')}: {formData.selectedTemplate}
|
||||
</Text>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* 提示词 */}
|
||||
<div className='relative mb-4'>
|
||||
<div className='absolute -inset-0.5 bg-gradient-to-r from-emerald-400/20 to-teal-400/20 rounded-[14px] blur-sm' />
|
||||
<Card
|
||||
title={
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
||||
<div className='p-1.5 bg-gradient-to-br from-emerald-500 to-teal-500 rounded-lg'>
|
||||
<Video size={14} className='text-white' />
|
||||
</div>
|
||||
<span className='font-semibold bg-clip-text text-transparent bg-gradient-to-r from-emerald-600 to-teal-600 dark:from-emerald-400 dark:to-teal-400'>
|
||||
{t('提示词')}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
className='relative bg-white/90 dark:bg-neutral-900/90 backdrop-blur-sm'
|
||||
style={{
|
||||
borderRadius: '12px',
|
||||
boxShadow: '0 4px 16px rgba(20, 184, 166, 0.08)',
|
||||
border: 'none',
|
||||
}}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
headerStyle={{ padding: '12px 16px' }}
|
||||
>
|
||||
<TextArea
|
||||
placeholder={t(
|
||||
'描述你想要生成的视频内容,例如:一只可爱的猫咪在草地上玩耍',
|
||||
)}
|
||||
value={formData.prompt}
|
||||
onChange={(value) => updateField('prompt', value)}
|
||||
autosize={{ minRows: 4, maxRows: 8 }}
|
||||
maxLength={2000}
|
||||
showClear
|
||||
/>
|
||||
<Text
|
||||
type='tertiary'
|
||||
size='small'
|
||||
style={{ marginTop: '8px', display: 'block' }}
|
||||
>
|
||||
{formData.prompt?.length || 0} / 2000
|
||||
</Text>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* 反向提示词 */}
|
||||
<div className='relative mb-4'>
|
||||
<div className='absolute -inset-0.5 bg-gradient-to-r from-rose-400/20 to-pink-400/20 rounded-[14px] blur-sm' />
|
||||
<Card
|
||||
title={
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
||||
<div className='p-1.5 bg-gradient-to-br from-rose-500 to-pink-500 rounded-lg'>
|
||||
<X size={14} className='text-white' />
|
||||
</div>
|
||||
<span className='font-semibold bg-clip-text text-transparent bg-gradient-to-r from-rose-600 to-pink-600 dark:from-rose-400 dark:to-pink-400'>
|
||||
{t('反向提示词')}
|
||||
</span>
|
||||
<Tooltip content={t('描述不希望出现的内容')}>
|
||||
<Info size={14} className='text-rose-400' />
|
||||
</Tooltip>
|
||||
</div>
|
||||
}
|
||||
className='relative bg-white/90 dark:bg-neutral-900/90 backdrop-blur-sm'
|
||||
style={{
|
||||
borderRadius: '12px',
|
||||
boxShadow: '0 4px 16px rgba(244, 63, 94, 0.08)',
|
||||
border: 'none',
|
||||
}}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
headerStyle={{ padding: '12px 16px' }}
|
||||
>
|
||||
<TextArea
|
||||
placeholder={t('例如:模糊、扭曲、低质量')}
|
||||
value={formData.negative_prompt}
|
||||
onChange={(value) => updateField('negative_prompt', value)}
|
||||
autosize={{ minRows: 2, maxRows: 4 }}
|
||||
maxLength={500}
|
||||
showClear
|
||||
/>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* 图片上传(图生视频时显示) */}
|
||||
{formData.mode === 'image2video' && (
|
||||
<div className='relative mb-4'>
|
||||
<div className='absolute -inset-0.5 bg-gradient-to-r from-blue-400/20 to-brand-to/20 rounded-[14px] blur-sm' />
|
||||
<Card
|
||||
title={
|
||||
<div
|
||||
style={{ display: 'flex', alignItems: 'center', gap: '8px' }}
|
||||
>
|
||||
<div className='p-1.5 bg-gradient-to-br from-blue-500 to-brand-to rounded-lg'>
|
||||
<ImageIcon size={14} className='text-white' />
|
||||
</div>
|
||||
<span className='font-semibold bg-clip-text text-transparent bg-gradient-to-r from-blue-600 to-brand-to dark:from-blue-400 dark:to-brand-to'>
|
||||
{t('首帧图片')}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
className='relative bg-white/90 dark:bg-neutral-900/90 backdrop-blur-sm'
|
||||
style={{
|
||||
borderRadius: '12px',
|
||||
boxShadow:
|
||||
'0 4px 16px color-mix(in srgb, var(--brand-primary) 8%, transparent)',
|
||||
border: 'none',
|
||||
}}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
headerStyle={{ padding: '12px 16px' }}
|
||||
>
|
||||
{formData.image ? (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
gap: '12px',
|
||||
padding: '12px',
|
||||
backgroundColor: 'var(--semi-color-fill-0)',
|
||||
borderRadius: '8px',
|
||||
border: '1px solid var(--semi-color-border)',
|
||||
}}
|
||||
>
|
||||
<img
|
||||
src={formData.imagePreview || formData.image}
|
||||
alt='Preview'
|
||||
style={{
|
||||
width: '64px',
|
||||
height: '64px',
|
||||
objectFit: 'cover',
|
||||
borderRadius: '6px',
|
||||
flexShrink: 0,
|
||||
}}
|
||||
/>
|
||||
<div style={{ minWidth: 0 }}>
|
||||
<Text
|
||||
ellipsis
|
||||
style={{
|
||||
display: 'block',
|
||||
fontSize: '13px',
|
||||
fontWeight: 500,
|
||||
}}
|
||||
>
|
||||
{formData.imageName ||
|
||||
formData.imageFile?.name ||
|
||||
t('已上传图片')}
|
||||
</Text>
|
||||
{formData.imageIdentityType === 'real_person' ? (
|
||||
<Tag color='green' size='small'>
|
||||
{t('真人人像')}
|
||||
</Tag>
|
||||
) : (
|
||||
<Text type='tertiary' size='small'>
|
||||
{formData.imageFile?.size
|
||||
? `${(formData.imageFile.size / 1024).toFixed(1)} KB`
|
||||
: ''}
|
||||
</Text>
|
||||
)}
|
||||
</div>
|
||||
<Tooltip content={t('删除图片')}>
|
||||
<Button
|
||||
size='small'
|
||||
type='danger'
|
||||
theme='borderless'
|
||||
icon={<X size={16} />}
|
||||
onClick={handleImageRemove}
|
||||
style={{ marginLeft: 'auto' }}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
) : (
|
||||
<Upload
|
||||
accept='image/*'
|
||||
limit={1}
|
||||
onChange={handleImageUpload}
|
||||
uploadTrigger='custom'
|
||||
draggable
|
||||
dragMainText={
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
gap: '8px',
|
||||
}}
|
||||
>
|
||||
<ImageIcon
|
||||
size={32}
|
||||
style={{ color: '#1890ff', opacity: 0.6 }}
|
||||
/>
|
||||
<span>{t('点击上传或拖拽图片到此处')}</span>
|
||||
</div>
|
||||
}
|
||||
dragSubText={t('支持 JPG、PNG 格式')}
|
||||
showUploadList={false}
|
||||
style={{
|
||||
border: '1px dashed var(--semi-color-border)',
|
||||
borderRadius: '8px',
|
||||
padding: '24px',
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<div style={{ marginTop: '12px', display: 'flex' }}>
|
||||
<PortraitAssetPicker
|
||||
onSelect={handlePortraitAssetSelect}
|
||||
selectedAssetId={
|
||||
formData.image?.startsWith('asset://')
|
||||
? formData.image.slice('asset://'.length)
|
||||
: ''
|
||||
}
|
||||
onClearSelection={handleImageRemove}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 高级参数 - 仅对阿里云模型显示 */}
|
||||
{showAdvancedParams && (
|
||||
<div className='relative'>
|
||||
<div className='absolute -inset-0.5 bg-gradient-to-r from-slate-400/20 to-gray-400/20 rounded-[14px] blur-sm' />
|
||||
<div
|
||||
className='relative bg-white/90 dark:bg-neutral-900/90 backdrop-blur-sm rounded-xl overflow-hidden'
|
||||
style={{ boxShadow: '0 4px 16px rgba(100, 116, 139, 0.08)' }}
|
||||
>
|
||||
<Collapse defaultActiveKey={[]} className='border-0'>
|
||||
<Collapse.Panel
|
||||
header={
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '8px',
|
||||
}}
|
||||
>
|
||||
<div className='p-1.5 bg-gradient-to-br from-slate-500 to-gray-600 rounded-lg'>
|
||||
<Settings2 size={14} className='text-white' />
|
||||
</div>
|
||||
<span className='font-semibold text-slate-700 dark:text-slate-300'>
|
||||
{t('高级参数')}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
itemKey='advanced'
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '20px',
|
||||
}}
|
||||
>
|
||||
{/* 分辨率 */}
|
||||
<div>
|
||||
<label
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '6px',
|
||||
marginBottom: '8px',
|
||||
fontSize: '14px',
|
||||
fontWeight: 500,
|
||||
}}
|
||||
>
|
||||
<Maximize size={16} style={{ color: '#1890ff' }} />
|
||||
{t('分辨率')}
|
||||
</label>
|
||||
<Select
|
||||
value={formData.resolution}
|
||||
onChange={(value) => updateField('resolution', value)}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<Select.Option value='480P'>480P (832x480)</Select.Option>
|
||||
<Select.Option value='720P'>
|
||||
720P (1280x720)
|
||||
</Select.Option>
|
||||
<Select.Option value='1080P'>
|
||||
1080P (1920x1080)
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* 时长 */}
|
||||
<div>
|
||||
<label
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '6px',
|
||||
marginBottom: '8px',
|
||||
fontSize: '14px',
|
||||
fontWeight: 500,
|
||||
}}
|
||||
>
|
||||
<Clock size={16} style={{ color: '#1890ff' }} />
|
||||
{t('时长(秒)')}
|
||||
</label>
|
||||
<InputNumber
|
||||
value={formData.duration}
|
||||
onChange={(value) => updateField('duration', value)}
|
||||
min={3}
|
||||
max={10}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 帧率 */}
|
||||
<div>
|
||||
<label
|
||||
style={{
|
||||
display: 'block',
|
||||
marginBottom: '8px',
|
||||
fontSize: '14px',
|
||||
fontWeight: 500,
|
||||
}}
|
||||
>
|
||||
{t('帧率')}
|
||||
</label>
|
||||
<Select
|
||||
value={formData.fps}
|
||||
onChange={(value) => updateField('fps', value)}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<Select.Option value={24}>24 FPS</Select.Option>
|
||||
<Select.Option value={30}>30 FPS</Select.Option>
|
||||
<Select.Option value={60}>60 FPS</Select.Option>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* 比例 */}
|
||||
<div>
|
||||
<label
|
||||
style={{
|
||||
display: 'block',
|
||||
marginBottom: '8px',
|
||||
fontSize: '14px',
|
||||
fontWeight: 500,
|
||||
}}
|
||||
>
|
||||
{t('画面比例')}
|
||||
</label>
|
||||
<Select
|
||||
value={formData.ratio}
|
||||
onChange={(value) => updateField('ratio', value)}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<Select.Option value='16:9'>
|
||||
{t('16:9 (横屏)')}
|
||||
</Select.Option>
|
||||
<Select.Option value='9:16'>
|
||||
{t('9:16 (竖屏)')}
|
||||
</Select.Option>
|
||||
<Select.Option value='1:1'>
|
||||
{t('1:1 (方形)')}
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* 音频 */}
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<label
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '6px',
|
||||
fontSize: '14px',
|
||||
fontWeight: 500,
|
||||
}}
|
||||
>
|
||||
<Mic size={16} style={{ color: '#1890ff' }} />
|
||||
{t('自动生成音频')}
|
||||
</label>
|
||||
<Switch
|
||||
checked={formData.audio}
|
||||
onChange={(checked) => updateField('audio', checked)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Seed */}
|
||||
<div>
|
||||
<label
|
||||
style={{
|
||||
display: 'block',
|
||||
marginBottom: '8px',
|
||||
fontSize: '14px',
|
||||
fontWeight: 500,
|
||||
}}
|
||||
>
|
||||
{t('随机种子')}
|
||||
</label>
|
||||
<InputNumber
|
||||
value={formData.seed}
|
||||
onChange={(value) => updateField('seed', value)}
|
||||
min={-1}
|
||||
max={999999999}
|
||||
style={{ width: '100%' }}
|
||||
placeholder={t('-1 表示随机')}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 提示词优化 */}
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<label
|
||||
style={{
|
||||
display: 'block',
|
||||
marginBottom: '4px',
|
||||
fontSize: '14px',
|
||||
fontWeight: 500,
|
||||
}}
|
||||
>
|
||||
{t('智能改写提示词')}
|
||||
</label>
|
||||
<Text type='tertiary' size='small'>
|
||||
{t('AI 自动优化提示词')}
|
||||
</Text>
|
||||
</div>
|
||||
<Switch
|
||||
checked={formData.prompt_extend}
|
||||
onChange={(checked) =>
|
||||
updateField('prompt_extend', checked)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 水印 */}
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<label
|
||||
style={{
|
||||
display: 'block',
|
||||
fontSize: '14px',
|
||||
fontWeight: 500,
|
||||
}}
|
||||
>
|
||||
{t('添加水印')}
|
||||
</label>
|
||||
<Switch
|
||||
checked={formData.watermark}
|
||||
onChange={(checked) => updateField('watermark', checked)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Collapse.Panel>
|
||||
</Collapse>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoInputPanel;
|
||||
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useEffect } from 'react';
|
||||
import { Card, Typography, Space, Tag } from '@douyinfe/semi-ui';
|
||||
import { IconCreditCard, IconTickCircle } from '@douyinfe/semi-icons';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import ModelSelector from '../../../../../components/common/ModelSelector';
|
||||
import { MODEL_CATEGORY } from '../../../../../constants';
|
||||
import { convertUSDToCurrency } from '../../../../../helpers';
|
||||
|
||||
const { Text, Paragraph } = Typography;
|
||||
|
||||
const VideoModelPanel = ({
|
||||
selectedModel,
|
||||
setSelectedModel,
|
||||
modelInfo,
|
||||
mode,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
// 根据模式动态获取模型分类
|
||||
const getModelCategory = () => {
|
||||
return mode === 'text2video'
|
||||
? MODEL_CATEGORY.TEXT_TO_VIDEO
|
||||
: MODEL_CATEGORY.IMAGE_TO_VIDEO;
|
||||
};
|
||||
|
||||
// 当模式切换时,清空选中的模型
|
||||
useEffect(() => {
|
||||
setSelectedModel(null);
|
||||
}, [mode, setSelectedModel]);
|
||||
|
||||
return (
|
||||
<div style={{ padding: '16px', height: '100%', overflow: 'auto' }}>
|
||||
{/* 模型选择 */}
|
||||
<Card
|
||||
title={t('选择模型')}
|
||||
style={{ marginBottom: '16px' }}
|
||||
bodyStyle={{ padding: '12px' }}
|
||||
>
|
||||
<ModelSelector
|
||||
key={mode}
|
||||
category={getModelCategory()}
|
||||
value={
|
||||
selectedModel?.id || selectedModel?.model_name || selectedModel
|
||||
}
|
||||
onChange={(model) => {
|
||||
// 传递完整的模型对象,而不仅仅是名称
|
||||
setSelectedModel(model);
|
||||
}}
|
||||
placeholder={t('请选择模型')}
|
||||
/>
|
||||
</Card>
|
||||
|
||||
{/* 模型信息 */}
|
||||
{modelInfo && (
|
||||
<Card
|
||||
title={t('模型信息')}
|
||||
style={{ marginBottom: '16px' }}
|
||||
bodyStyle={{ padding: '12px' }}
|
||||
>
|
||||
<Space vertical spacing='medium' style={{ width: '100%' }}>
|
||||
{/* 厂商 */}
|
||||
<div>
|
||||
<Text type='tertiary'>{t('厂商')}</Text>
|
||||
<div style={{ marginTop: '4px' }}>
|
||||
<Tag>{modelInfo.provider}</Tag>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 模型描述 */}
|
||||
{modelInfo.description && (
|
||||
<div>
|
||||
<Text type='tertiary'>{t('描述')}</Text>
|
||||
<Paragraph style={{ marginTop: '4px', marginBottom: 0 }}>
|
||||
{modelInfo.description}
|
||||
</Paragraph>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 能力特点 */}
|
||||
{modelInfo.features && modelInfo.features.length > 0 && (
|
||||
<div>
|
||||
<Text type='tertiary'>{t('能力特点')}</Text>
|
||||
<Space wrap style={{ marginTop: '4px' }}>
|
||||
{modelInfo.features.map((feature, index) => (
|
||||
<Tag key={index} color='blue'>
|
||||
<IconTickCircle
|
||||
size='small'
|
||||
style={{ marginRight: '4px' }}
|
||||
/>
|
||||
{feature}
|
||||
</Tag>
|
||||
))}
|
||||
</Space>
|
||||
</div>
|
||||
)}
|
||||
</Space>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* 模型价格 —— 单价为 0(含管理员隐藏价格场景)时不展示,避免误导性的 0.00 */}
|
||||
{Number(modelInfo?.price) > 0 && (
|
||||
<Card
|
||||
title={
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '4px' }}>
|
||||
<IconCreditCard />
|
||||
<span>{t('模型价格')}</span>
|
||||
</div>
|
||||
}
|
||||
bodyStyle={{ padding: '12px' }}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<Text type='tertiary'>{t('单价')}</Text>
|
||||
<Text
|
||||
strong
|
||||
style={{ fontSize: '18px', color: 'var(--semi-color-primary)' }}
|
||||
>
|
||||
{convertUSDToCurrency(Number(modelInfo?.price || 0), 6)}
|
||||
</Text>
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoModelPanel;
|
||||
@@ -0,0 +1,66 @@
|
||||
/* 视频预览面板 - 电影感动画背景(增强版) */
|
||||
|
||||
/* 动态光晕1 - 缓慢飘动 */
|
||||
@keyframes videoPreviewFloat1 {
|
||||
0%,
|
||||
100% {
|
||||
transform: translate3d(0, 0, 0);
|
||||
}
|
||||
25% {
|
||||
transform: translate3d(50px, -30px, 0);
|
||||
}
|
||||
50% {
|
||||
transform: translate3d(80px, 20px, 0);
|
||||
}
|
||||
75% {
|
||||
transform: translate3d(30px, 50px, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 动态光晕2 - 反向飘动 */
|
||||
@keyframes videoPreviewFloat2 {
|
||||
0%,
|
||||
100% {
|
||||
transform: translate3d(0, 0, 0);
|
||||
}
|
||||
25% {
|
||||
transform: translate3d(-60px, 40px, 0);
|
||||
}
|
||||
50% {
|
||||
transform: translate3d(-30px, -50px, 0);
|
||||
}
|
||||
75% {
|
||||
transform: translate3d(-70px, -20px, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 脉动效果 */
|
||||
@keyframes videoPreviewPulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0.4;
|
||||
transform: scale(1);
|
||||
}
|
||||
50% {
|
||||
opacity: 1;
|
||||
transform: scale(1.1);
|
||||
}
|
||||
}
|
||||
|
||||
/* 动画类 - GPU 加速 */
|
||||
.video-preview-glow1 {
|
||||
animation: videoPreviewFloat1 12s ease-in-out infinite;
|
||||
will-change: transform;
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
|
||||
.video-preview-glow2 {
|
||||
animation: videoPreviewFloat2 15s ease-in-out infinite;
|
||||
will-change: transform;
|
||||
backface-visibility: hidden;
|
||||
}
|
||||
|
||||
.video-preview-glow3 {
|
||||
animation: videoPreviewPulse 6s ease-in-out infinite;
|
||||
will-change: opacity, transform;
|
||||
}
|
||||
@@ -0,0 +1,855 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Card,
|
||||
Button,
|
||||
Progress,
|
||||
Empty,
|
||||
Space,
|
||||
Typography,
|
||||
Spin,
|
||||
Tooltip,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import {
|
||||
Play,
|
||||
Square,
|
||||
Download,
|
||||
RotateCcw,
|
||||
Share2,
|
||||
Film,
|
||||
HelpCircle,
|
||||
X,
|
||||
Loader2,
|
||||
} from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
canCancelVideoTask,
|
||||
canRegenerateVideoTask,
|
||||
getVideoURLFromDetail,
|
||||
normalizeVideoTaskStatus,
|
||||
} from '../../../../../helpers/videoTask';
|
||||
import './VideoPreviewPanel.css';
|
||||
|
||||
const { Title, Text, Paragraph } = Typography;
|
||||
|
||||
const VideoPreviewPanel = ({
|
||||
formData,
|
||||
generating,
|
||||
currentTask,
|
||||
onGenerate,
|
||||
onCancel,
|
||||
selectedModel,
|
||||
selectedTaskForPlay, // 新增:从任务列表选择的任务
|
||||
onRegenerate, // 新增:再生成回调
|
||||
onClearSelectedTask, // 新增:清除选中任务的回调(关闭视频播放)
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
|
||||
|
||||
// 监听窗口大小变化
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
setWindowWidth(window.innerWidth);
|
||||
};
|
||||
|
||||
window.addEventListener('resize', handleResize);
|
||||
return () => window.removeEventListener('resize', handleResize);
|
||||
}, []);
|
||||
|
||||
// 根据屏幕宽度获取响应式配置
|
||||
const getResponsiveConfig = () => {
|
||||
if (windowWidth > 1600) {
|
||||
return {
|
||||
minHeight: '400px',
|
||||
padding: '40px',
|
||||
videoMaxHeight: '600px',
|
||||
buttonSize: 'large',
|
||||
titleSize: 4,
|
||||
iconSize: 64,
|
||||
progressWidth: 120,
|
||||
};
|
||||
}
|
||||
if (windowWidth > 1280) {
|
||||
return {
|
||||
minHeight: '350px',
|
||||
padding: '32px',
|
||||
videoMaxHeight: '500px',
|
||||
buttonSize: 'default',
|
||||
titleSize: 5,
|
||||
iconSize: 56,
|
||||
progressWidth: 100,
|
||||
};
|
||||
}
|
||||
if (windowWidth > 1024) {
|
||||
return {
|
||||
minHeight: '300px',
|
||||
padding: '24px',
|
||||
videoMaxHeight: '400px',
|
||||
buttonSize: 'default',
|
||||
titleSize: 5,
|
||||
iconSize: 48,
|
||||
progressWidth: 90,
|
||||
};
|
||||
}
|
||||
// 小屏幕
|
||||
return {
|
||||
minHeight: '250px',
|
||||
padding: '16px',
|
||||
videoMaxHeight: '350px',
|
||||
buttonSize: 'small',
|
||||
titleSize: 6,
|
||||
iconSize: 40,
|
||||
progressWidth: 80,
|
||||
};
|
||||
};
|
||||
|
||||
const config = getResponsiveConfig();
|
||||
|
||||
// 处理下载
|
||||
const handleDownload = () => {
|
||||
const task = selectedTaskForPlay || currentTask;
|
||||
const videoUrl = getVideoURLFromDetail(task);
|
||||
|
||||
if (videoUrl) {
|
||||
const link = document.createElement('a');
|
||||
link.href = videoUrl;
|
||||
link.download = `video_${task.task_id || 'download'}.mp4`;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
};
|
||||
|
||||
// 处理分享
|
||||
const handleShare = async () => {
|
||||
const task = selectedTaskForPlay || currentTask;
|
||||
const videoUrl = getVideoURLFromDetail(task);
|
||||
|
||||
if (videoUrl) {
|
||||
if (navigator.share) {
|
||||
try {
|
||||
await navigator.share({
|
||||
title: t('视频分享'),
|
||||
text: task.prompt || t('AI生成的视频'),
|
||||
url: videoUrl,
|
||||
});
|
||||
} catch (err) {
|
||||
// 用户取消分享或分享失败
|
||||
copyToClipboard(videoUrl);
|
||||
}
|
||||
} else {
|
||||
// 不支持分享API,复制链接
|
||||
copyToClipboard(videoUrl);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 复制到剪贴板
|
||||
const copyToClipboard = (text) => {
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
// 可以添加提示
|
||||
console.log('链接已复制到剪贴板');
|
||||
});
|
||||
} else {
|
||||
// 兼容旧浏览器
|
||||
const textArea = document.createElement('textarea');
|
||||
textArea.value = text;
|
||||
document.body.appendChild(textArea);
|
||||
textArea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textArea);
|
||||
}
|
||||
};
|
||||
|
||||
// 处理生成视频(同时关闭当前播放的视频)
|
||||
const handleGenerate = () => {
|
||||
// 先清除选中的任务,关闭视频播放窗口
|
||||
if (onClearSelectedTask) {
|
||||
onClearSelectedTask();
|
||||
}
|
||||
// 然后开始生成
|
||||
if (onGenerate) {
|
||||
onGenerate();
|
||||
}
|
||||
};
|
||||
|
||||
// 处理关闭视频播放窗口
|
||||
const handleCloseVideo = () => {
|
||||
if (onClearSelectedTask) {
|
||||
onClearSelectedTask();
|
||||
}
|
||||
};
|
||||
|
||||
// 处理重新生成
|
||||
const handleRegenerate = () => {
|
||||
const task = selectedTaskForPlay || currentTask;
|
||||
if (onRegenerate && task) {
|
||||
onRegenerate(task);
|
||||
} else {
|
||||
// 如果没有提供 onRegenerate 回调,则直接调用 onGenerate
|
||||
onGenerate();
|
||||
}
|
||||
};
|
||||
|
||||
// 判断按钮是否禁用
|
||||
const isButtonDisabled =
|
||||
(!formData.prompt && !formData.selectedTemplate) ||
|
||||
!selectedModel ||
|
||||
(typeof selectedModel === 'object' && selectedModel.level_locked) ||
|
||||
(formData.mode === 'image2video' && !formData.image);
|
||||
|
||||
// 渲染顶部操作栏(始终显示)
|
||||
const renderTopBar = () => {
|
||||
// 优先显示从任务列表选择的任务
|
||||
const displayTask = selectedTaskForPlay || currentTask;
|
||||
const normalizedStatus = normalizeVideoTaskStatus(displayTask?.status);
|
||||
const isCompleted = normalizedStatus === 'success';
|
||||
|
||||
// 检查是否有视频URL
|
||||
let _hasVideo = false;
|
||||
if (displayTask) {
|
||||
const videoUrl = getVideoURLFromDetail(displayTask);
|
||||
_hasVideo = isCompleted && !!videoUrl;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
padding: windowWidth > 768 ? '16px 20px' : '12px 16px',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '12px',
|
||||
backgroundColor: 'var(--semi-color-bg-1)',
|
||||
borderBottom: '1px solid var(--semi-color-border)',
|
||||
flexShrink: 0,
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
type='primary'
|
||||
theme='solid'
|
||||
size={windowWidth > 768 ? 'default' : 'small'}
|
||||
icon={<Play size={16} fill='currentColor' />}
|
||||
onClick={isButtonDisabled ? undefined : handleGenerate}
|
||||
disabled={isButtonDisabled || generating}
|
||||
style={{
|
||||
fontWeight: 600,
|
||||
background:
|
||||
isButtonDisabled || generating
|
||||
? undefined
|
||||
: 'linear-gradient(135deg, #1890ff 0%, #0050b3 100%)',
|
||||
border: 'none',
|
||||
}}
|
||||
>
|
||||
{generating
|
||||
? t('生成中...')
|
||||
: windowWidth > 768
|
||||
? t('开始生成')
|
||||
: t('生成')}
|
||||
</Button>
|
||||
|
||||
{/* 禁用提示 */}
|
||||
{isButtonDisabled && !generating && (
|
||||
<Text type='tertiary' style={{ fontSize: '12px' }}>
|
||||
{!selectedModel && t('请选择模型')}
|
||||
{selectedModel &&
|
||||
typeof selectedModel === 'object' &&
|
||||
selectedModel.level_locked &&
|
||||
t('当前等级无权调用此模型')}
|
||||
{selectedModel &&
|
||||
!(
|
||||
typeof selectedModel === 'object' && selectedModel.level_locked
|
||||
) &&
|
||||
!formData.prompt &&
|
||||
!formData.selectedTemplate &&
|
||||
t('请输入提示词或选择模板')}
|
||||
{selectedModel &&
|
||||
!(
|
||||
typeof selectedModel === 'object' && selectedModel.level_locked
|
||||
) &&
|
||||
(formData.prompt || formData.selectedTemplate) &&
|
||||
formData.mode === 'image2video' &&
|
||||
!formData.image &&
|
||||
t('请上传图片')}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
{/* 生成中状态提示 */}
|
||||
{generating && displayTask && (
|
||||
<Text
|
||||
type='tertiary'
|
||||
style={{
|
||||
fontSize: '12px',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '4px',
|
||||
}}
|
||||
>
|
||||
<Loader2 size={12} className='animate-spin' />
|
||||
{displayTask.progress || '0%'}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
<div style={{ flex: 1 }} />
|
||||
|
||||
<Tooltip
|
||||
content={
|
||||
<div style={{ padding: '12px', maxWidth: '300px' }}>
|
||||
<div
|
||||
style={{
|
||||
fontWeight: 600,
|
||||
marginBottom: '8px',
|
||||
fontSize: '14px',
|
||||
}}
|
||||
>
|
||||
{t('使用提示')}
|
||||
</div>
|
||||
<div style={{ fontSize: '13px', lineHeight: '1.8' }}>
|
||||
• {t('详细的提示词能获得更好的效果')}
|
||||
<br />• {t('建议使用高质量的首帧图片')}
|
||||
<br />• {t('视频生成可能需要 1-3 分钟')}
|
||||
<br />• {t('可在任务队列中查看历史记录')}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
position='bottomRight'
|
||||
trigger='hover'
|
||||
showArrow={true}
|
||||
>
|
||||
<Button
|
||||
icon={<HelpCircle size={18} />}
|
||||
type='tertiary'
|
||||
size={windowWidth > 768 ? 'default' : 'small'}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// 渲染预览区域
|
||||
const renderPreview = () => {
|
||||
// 优先显示从任务列表选择的任务
|
||||
const displayTask = selectedTaskForPlay || currentTask;
|
||||
|
||||
// 统一转换状态为小写进行比较
|
||||
const normalizedStatus = normalizeVideoTaskStatus(displayTask?.status);
|
||||
|
||||
// 生成完成 - 优先检查,包括从任务列表点击播放的情况
|
||||
const isCompleted = normalizedStatus === 'success';
|
||||
const videoUrl = getVideoURLFromDetail(displayTask);
|
||||
const taskData = displayTask?.request || {};
|
||||
|
||||
// 如果是已完成的任务且有视频URL,直接显示(无论是从任务列表还是当前生成)
|
||||
if (isCompleted && videoUrl) {
|
||||
return (
|
||||
<div style={{ textAlign: 'center', padding: config.padding }}>
|
||||
{/* 视频播放器容器 */}
|
||||
<div
|
||||
style={{
|
||||
position: 'relative',
|
||||
marginBottom: windowWidth > 768 ? '24px' : '16px',
|
||||
}}
|
||||
>
|
||||
{/* 关闭按钮 */}
|
||||
<Button
|
||||
icon={<X size={16} />}
|
||||
type='tertiary'
|
||||
theme='borderless'
|
||||
size='small'
|
||||
onClick={handleCloseVideo}
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: '8px',
|
||||
right: '8px',
|
||||
zIndex: 10,
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
||||
color: 'white',
|
||||
borderRadius: '50%',
|
||||
}}
|
||||
/>
|
||||
{/* 视频播放器 */}
|
||||
<video
|
||||
controls
|
||||
style={{
|
||||
width: '100%',
|
||||
maxHeight: config.videoMaxHeight,
|
||||
borderRadius: '8px',
|
||||
}}
|
||||
src={videoUrl}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 操作按钮 */}
|
||||
<Space wrap={windowWidth <= 768}>
|
||||
<Button
|
||||
type='primary'
|
||||
size={config.buttonSize}
|
||||
icon={<Download size={16} />}
|
||||
onClick={handleDownload}
|
||||
>
|
||||
{windowWidth > 768 ? t('下载视频') : t('下载')}
|
||||
</Button>
|
||||
<Button
|
||||
size={config.buttonSize}
|
||||
icon={<Share2 size={16} />}
|
||||
onClick={handleShare}
|
||||
>
|
||||
{t('分享')}
|
||||
</Button>
|
||||
{canRegenerateVideoTask(displayTask) && (
|
||||
<Button
|
||||
size={config.buttonSize}
|
||||
icon={<RotateCcw size={16} />}
|
||||
onClick={handleRegenerate}
|
||||
>
|
||||
{windowWidth > 768 ? t('再生成') : t('重新')}
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
|
||||
{/* 视频信息 */}
|
||||
<div
|
||||
style={{
|
||||
marginTop: windowWidth > 768 ? '24px' : '16px',
|
||||
padding: windowWidth > 768 ? '16px' : '12px',
|
||||
backgroundColor: 'var(--semi-color-fill-0)',
|
||||
borderRadius: '8px',
|
||||
textAlign: 'left',
|
||||
}}
|
||||
>
|
||||
<Space vertical spacing='small' style={{ width: '100%' }}>
|
||||
{(taskData.prompt || displayTask.prompt) && (
|
||||
<div>
|
||||
<Text
|
||||
strong
|
||||
style={{ fontSize: windowWidth > 768 ? '14px' : '12px' }}
|
||||
>
|
||||
{t('提示词')}:
|
||||
</Text>
|
||||
<Paragraph
|
||||
copyable
|
||||
style={{
|
||||
fontSize: windowWidth > 768 ? '13px' : '11px',
|
||||
marginTop: '4px',
|
||||
}}
|
||||
>
|
||||
{taskData.prompt || displayTask.prompt}
|
||||
</Paragraph>
|
||||
</div>
|
||||
)}
|
||||
{taskData.negative_prompt && (
|
||||
<div>
|
||||
<Text
|
||||
strong
|
||||
style={{ fontSize: windowWidth > 768 ? '14px' : '12px' }}
|
||||
>
|
||||
{t('反向提示词')}:
|
||||
</Text>
|
||||
<Paragraph
|
||||
copyable
|
||||
style={{
|
||||
fontSize: windowWidth > 768 ? '13px' : '11px',
|
||||
marginTop: '4px',
|
||||
}}
|
||||
>
|
||||
{taskData.negative_prompt}
|
||||
</Paragraph>
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<Text
|
||||
type='tertiary'
|
||||
style={{ fontSize: windowWidth > 768 ? '12px' : '10px' }}
|
||||
>
|
||||
{t('模型')}:{' '}
|
||||
{taskData.model ||
|
||||
displayTask.properties?.upstream_model_name ||
|
||||
displayTask.properties?.origin_model_name ||
|
||||
(typeof selectedModel === 'object'
|
||||
? selectedModel?.model_name
|
||||
: selectedModel)}{' '}
|
||||
| {t('时长')}:{' '}
|
||||
{taskData.duration || displayTask.properties?.duration || '-'}
|
||||
s | {t('分辨率')}:{' '}
|
||||
{taskData.resolution ||
|
||||
displayTask.properties?.resolution ||
|
||||
'-'}
|
||||
</Text>
|
||||
</div>
|
||||
</Space>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 生成中(只在没有 selectedTaskForPlay 时显示)
|
||||
if (generating && displayTask && !selectedTaskForPlay) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
minHeight: config.minHeight,
|
||||
padding: config.padding,
|
||||
}}
|
||||
>
|
||||
<Spin
|
||||
size={windowWidth > 768 ? 'large' : 'default'}
|
||||
indicator={<Loader2 className='animate-spin' size={32} />}
|
||||
/>
|
||||
<Title
|
||||
heading={config.titleSize}
|
||||
style={{ marginTop: '24px', marginBottom: '8px' }}
|
||||
>
|
||||
{t('视频生成中...')}
|
||||
</Title>
|
||||
<Text
|
||||
type='tertiary'
|
||||
style={{ fontSize: windowWidth > 768 ? '14px' : '12px' }}
|
||||
>
|
||||
{normalizedStatus === 'queued' && t('等待处理')}
|
||||
{normalizedStatus === 'in_progress' && t('正在生成')}
|
||||
</Text>
|
||||
|
||||
{/* 进度条 */}
|
||||
{displayTask.progress !== undefined &&
|
||||
(() => {
|
||||
// 解析进度值,处理字符串格式(如 "50%")
|
||||
let percentValue = 0;
|
||||
if (typeof displayTask.progress === 'string') {
|
||||
percentValue =
|
||||
parseInt(displayTask.progress.replace('%', '')) || 0;
|
||||
} else if (typeof displayTask.progress === 'number') {
|
||||
percentValue = displayTask.progress;
|
||||
}
|
||||
|
||||
return (
|
||||
<Progress
|
||||
percent={percentValue}
|
||||
showInfo
|
||||
type='circle'
|
||||
style={{ marginTop: '24px' }}
|
||||
width={config.progressWidth}
|
||||
/>
|
||||
);
|
||||
})()}
|
||||
|
||||
{/* 任务信息 */}
|
||||
<div style={{ marginTop: '24px', textAlign: 'center' }}>
|
||||
<Space vertical spacing='small'>
|
||||
<Text
|
||||
type='tertiary'
|
||||
style={{ fontSize: windowWidth > 768 ? '13px' : '11px' }}
|
||||
>
|
||||
{t('任务ID')}: {displayTask.task_id}
|
||||
</Text>
|
||||
<Text
|
||||
type='tertiary'
|
||||
style={{ fontSize: windowWidth > 768 ? '13px' : '11px' }}
|
||||
>
|
||||
{t('模型')}:{' '}
|
||||
{typeof selectedModel === 'object'
|
||||
? selectedModel?.model_name
|
||||
: selectedModel}
|
||||
</Text>
|
||||
{displayTask.estimated_time && (
|
||||
<Text
|
||||
type='tertiary'
|
||||
style={{ fontSize: windowWidth > 768 ? '13px' : '11px' }}
|
||||
>
|
||||
{t('预计时间')}: {displayTask.estimated_time}s
|
||||
</Text>
|
||||
)}
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
{canCancelVideoTask(displayTask) && (
|
||||
<Button
|
||||
type='danger'
|
||||
size={config.buttonSize}
|
||||
icon={<Square size={16} fill='currentColor' />}
|
||||
onClick={onCancel}
|
||||
style={{ marginTop: '32px' }}
|
||||
>
|
||||
{t('取消生成')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 生成失败 - 检查 'failed' 或 'failure' 状态
|
||||
const isFailed =
|
||||
normalizedStatus === 'failed' || normalizedStatus === 'failure';
|
||||
if (isFailed) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
minHeight: config.minHeight,
|
||||
padding: config.padding,
|
||||
}}
|
||||
>
|
||||
<Empty
|
||||
title={t('生成失败')}
|
||||
description={
|
||||
displayTask.fail_reason || displayTask.error || t('未知错误')
|
||||
}
|
||||
/>
|
||||
{canRegenerateVideoTask(displayTask) && (
|
||||
<Button
|
||||
type='primary'
|
||||
size={config.buttonSize}
|
||||
icon={<RotateCcw size={16} />}
|
||||
onClick={handleRegenerate}
|
||||
style={{ marginTop: '24px' }}
|
||||
>
|
||||
{t('重新生成')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 初始状态或图生视频预览
|
||||
if (formData.mode === 'image2video' && formData.image) {
|
||||
return (
|
||||
<div style={{ textAlign: 'center', padding: config.padding }}>
|
||||
<Title
|
||||
heading={config.titleSize + 1}
|
||||
style={{ marginBottom: '16px' }}
|
||||
>
|
||||
{t('首帧预览')}
|
||||
</Title>
|
||||
<img
|
||||
src={formData.imagePreview || formData.image}
|
||||
alt='Preview'
|
||||
style={{
|
||||
maxWidth: '100%',
|
||||
maxHeight: windowWidth > 1024 ? '500px' : '350px',
|
||||
borderRadius: '8px',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 默认空状态 - 纯CSS电影感动画背景(无网络资源消耗)
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
minHeight: config.minHeight,
|
||||
height: '100%',
|
||||
position: 'relative',
|
||||
borderRadius: '12px',
|
||||
overflow: 'hidden',
|
||||
margin: '16px',
|
||||
background:
|
||||
'linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%)',
|
||||
}}
|
||||
>
|
||||
{/* CSS动画背景 - 流动光效(增强版) */}
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
overflow: 'hidden',
|
||||
pointerEvents: 'none',
|
||||
}}
|
||||
>
|
||||
{/* 动态光晕1 - 紫色 */}
|
||||
<div
|
||||
className='video-preview-glow1'
|
||||
style={{
|
||||
position: 'absolute',
|
||||
width: '60%',
|
||||
height: '60%',
|
||||
top: '10%',
|
||||
left: '5%',
|
||||
background:
|
||||
'radial-gradient(ellipse at center, color-mix(in srgb, var(--brand-gradient-via) 35%, transparent) 0%, color-mix(in srgb, var(--brand-gradient-via) 10%, transparent) 40%, transparent 70%)',
|
||||
borderRadius: '50%',
|
||||
filter: 'blur(40px)',
|
||||
}}
|
||||
/>
|
||||
{/* 动态光晕2 - 橙红色 */}
|
||||
<div
|
||||
className='video-preview-glow2'
|
||||
style={{
|
||||
position: 'absolute',
|
||||
width: '50%',
|
||||
height: '50%',
|
||||
bottom: '10%',
|
||||
right: '5%',
|
||||
background:
|
||||
'radial-gradient(ellipse at center, rgba(251, 146, 60, 0.3) 0%, rgba(251, 146, 60, 0.1) 40%, transparent 70%)',
|
||||
borderRadius: '50%',
|
||||
filter: 'blur(40px)',
|
||||
}}
|
||||
/>
|
||||
{/* 动态光晕3 - 金色中心 */}
|
||||
<div
|
||||
className='video-preview-glow3'
|
||||
style={{
|
||||
position: 'absolute',
|
||||
width: '40%',
|
||||
height: '40%',
|
||||
top: '30%',
|
||||
left: '30%',
|
||||
background:
|
||||
'radial-gradient(ellipse at center, rgba(251, 191, 36, 0.25) 0%, transparent 60%)',
|
||||
borderRadius: '50%',
|
||||
filter: 'blur(30px)',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 电影宽银幕效果 - 上下黑边 */}
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: '6%',
|
||||
background:
|
||||
'linear-gradient(180deg, rgba(0,0,0,0.95) 0%, transparent 100%)',
|
||||
zIndex: 2,
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: '6%',
|
||||
background:
|
||||
'linear-gradient(0deg, rgba(0,0,0,0.95) 0%, transparent 100%)',
|
||||
zIndex: 2,
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* 中央内容区域 */}
|
||||
<div
|
||||
style={{
|
||||
flex: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
padding: config.padding,
|
||||
color: 'white',
|
||||
position: 'relative',
|
||||
zIndex: 3,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'rgba(255, 255, 255, 0.1)',
|
||||
borderRadius: '50%',
|
||||
padding: windowWidth > 1024 ? '32px' : '24px',
|
||||
marginBottom: windowWidth > 768 ? '32px' : '24px',
|
||||
border: '1px solid rgba(255, 255, 255, 0.2)',
|
||||
boxShadow: '0 8px 32px rgba(0, 0, 0, 0.3)',
|
||||
transition: 'transform 0.3s ease',
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
e.currentTarget.style.transform = 'scale(1.05)';
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
e.currentTarget.style.transform = 'scale(1)';
|
||||
}}
|
||||
>
|
||||
<Film
|
||||
size={config.iconSize}
|
||||
style={{
|
||||
color: 'rgba(255, 220, 180, 0.9)',
|
||||
filter: 'drop-shadow(0 2px 12px rgba(255,200,150,0.4))',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Title
|
||||
heading={config.titleSize}
|
||||
style={{
|
||||
marginBottom: '12px',
|
||||
color: 'rgba(255, 250, 245, 0.95)',
|
||||
fontWeight: 700,
|
||||
textShadow: '0 4px 20px rgba(0, 0, 0, 0.6)',
|
||||
letterSpacing: '3px',
|
||||
}}
|
||||
>
|
||||
{t('AI 视频生成')}
|
||||
</Title>
|
||||
|
||||
<Text
|
||||
style={{
|
||||
marginBottom: windowWidth > 768 ? '24px' : '16px',
|
||||
textAlign: 'center',
|
||||
fontSize: windowWidth > 768 ? '16px' : '14px',
|
||||
padding: '0 16px',
|
||||
color: 'rgba(255, 255, 255, 0.7)',
|
||||
maxWidth: '500px',
|
||||
lineHeight: '1.8',
|
||||
textShadow: '0 2px 8px rgba(0, 0, 0, 0.5)',
|
||||
}}
|
||||
>
|
||||
{formData.mode === 'text2video'
|
||||
? t('输入提示词,让 AI 为你创造精彩视频')
|
||||
: t('上传图片并输入提示词,生成动态视频')}
|
||||
</Text>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Card
|
||||
style={{ height: '100%', display: 'flex', flexDirection: 'column' }}
|
||||
bodyStyle={{
|
||||
flex: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
overflow: 'hidden',
|
||||
padding: 0,
|
||||
}}
|
||||
>
|
||||
{/* 始终显示的顶部操作栏 */}
|
||||
{renderTopBar()}
|
||||
|
||||
{/* 内容区域 */}
|
||||
<div style={{ flex: 1, overflow: 'auto' }}>{renderPreview()}</div>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoPreviewPanel;
|
||||
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Modal,
|
||||
Form,
|
||||
Select,
|
||||
Input,
|
||||
InputNumber,
|
||||
Switch,
|
||||
Space,
|
||||
Typography,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useIsMobile } from '../../../../../hooks/common/useIsMobile';
|
||||
import ModelSelector from '../../../../../components/common/ModelSelector';
|
||||
import { MODEL_CATEGORY } from '../../../../../constants';
|
||||
import { buildVideoRegenerateRequest } from '../../../../../helpers/videoTask';
|
||||
|
||||
const { TextArea } = Input;
|
||||
const { Text } = Typography;
|
||||
|
||||
const VideoRegenerateModal = ({ visible, onCancel, onConfirm, task }) => {
|
||||
const isNarrow = useIsMobile();
|
||||
const { t } = useTranslation();
|
||||
const [formData, setFormData] = useState({
|
||||
mode: 'text2video',
|
||||
prompt: '',
|
||||
negative_prompt: '',
|
||||
resolution: '1080P',
|
||||
duration: 5,
|
||||
fps: 30,
|
||||
ratio: '16:9',
|
||||
audio: false,
|
||||
seed: -1,
|
||||
prompt_extend: false,
|
||||
watermark: false,
|
||||
image: '',
|
||||
});
|
||||
const [selectedModel, setSelectedModel] = useState('');
|
||||
|
||||
// 从任务数据中提取参数
|
||||
useEffect(() => {
|
||||
if (task && visible) {
|
||||
const taskData = task.request || {};
|
||||
const mode = taskData.mode || 'text2video';
|
||||
const prompt = taskData.prompt || '';
|
||||
const negativePrompt = taskData.negative_prompt || '';
|
||||
const resolution = taskData.resolution || '1080P';
|
||||
const duration = taskData.duration || 5;
|
||||
const fps = taskData.fps || 30;
|
||||
const ratio = taskData.ratio || '16:9';
|
||||
const audio = taskData.audio === true;
|
||||
const seed = taskData.seed ?? -1;
|
||||
const promptExtend = taskData.prompt_extend === true;
|
||||
const watermark = taskData.watermark === true;
|
||||
const image = taskData.image || '';
|
||||
const model = taskData.model || '';
|
||||
|
||||
setFormData({
|
||||
mode,
|
||||
prompt,
|
||||
negative_prompt: negativePrompt,
|
||||
resolution,
|
||||
duration,
|
||||
fps,
|
||||
ratio,
|
||||
audio,
|
||||
seed,
|
||||
prompt_extend: promptExtend,
|
||||
watermark,
|
||||
image,
|
||||
});
|
||||
|
||||
setSelectedModel(model);
|
||||
}
|
||||
}, [task, visible]);
|
||||
|
||||
// 处理表单提交
|
||||
const handleSubmit = () => {
|
||||
if (!selectedModel || typeof selectedModel !== 'object') {
|
||||
return;
|
||||
}
|
||||
|
||||
// 构建请求数据
|
||||
onConfirm(buildVideoRegenerateRequest(formData, selectedModel));
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('再生成视频')}
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
onOk={handleSubmit}
|
||||
okText={t('确认生成')}
|
||||
cancelText={t('取消')}
|
||||
width={700}
|
||||
bodyStyle={{
|
||||
maxHeight: '70vh',
|
||||
overflowX: 'hidden',
|
||||
overflowY: 'auto',
|
||||
}}
|
||||
>
|
||||
<Form
|
||||
// 窄屏改为标签在上:labelWidth=120 在 ~294px 的弹窗体里要吃掉 41%,
|
||||
// 剩给控件的宽度放不下 seed 输入框和它的说明文案
|
||||
labelPosition={isNarrow ? 'top' : 'left'}
|
||||
labelAlign='right'
|
||||
labelWidth={isNarrow ? undefined : 120}
|
||||
>
|
||||
{/* 生成模式 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('生成模式')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<Select
|
||||
value={formData.mode}
|
||||
onChange={(value) => {
|
||||
setFormData({ ...formData, mode: value });
|
||||
setSelectedModel('');
|
||||
}}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<Select.Option value='text2video'>{t('文生视频')}</Select.Option>
|
||||
<Select.Option value='image2video'>{t('图生视频')}</Select.Option>
|
||||
</Select>
|
||||
</Form.Input>
|
||||
|
||||
{/* 模型选择 */}
|
||||
<Form.Label required>
|
||||
<Text strong>{t('选择模型')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<ModelSelector
|
||||
key={formData.mode}
|
||||
category={
|
||||
formData.mode === 'text2video'
|
||||
? MODEL_CATEGORY.TEXT_TO_VIDEO
|
||||
: MODEL_CATEGORY.IMAGE_TO_VIDEO
|
||||
}
|
||||
value={
|
||||
selectedModel?.id || selectedModel?.model_name || selectedModel
|
||||
}
|
||||
onChange={setSelectedModel}
|
||||
placeholder={t('请选择模型')}
|
||||
autoSelectFirst={false}
|
||||
onModelsLoaded={(models) => {
|
||||
if (typeof selectedModel !== 'string' || !selectedModel) return;
|
||||
const match = models.find(
|
||||
(model) => model.model_name === selectedModel,
|
||||
);
|
||||
setSelectedModel(match || '');
|
||||
}}
|
||||
/>
|
||||
</Form.Input>
|
||||
|
||||
{/* 提示词 */}
|
||||
<Form.Label required>
|
||||
<Text strong>{t('提示词')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<TextArea
|
||||
value={formData.prompt}
|
||||
onChange={(value) => setFormData({ ...formData, prompt: value })}
|
||||
placeholder={t('描述你想生成的视频内容')}
|
||||
rows={3}
|
||||
maxLength={2000}
|
||||
showClear
|
||||
/>
|
||||
</Form.Input>
|
||||
|
||||
{/* 反向提示词 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('反向提示词')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<TextArea
|
||||
value={formData.negative_prompt}
|
||||
onChange={(value) =>
|
||||
setFormData({ ...formData, negative_prompt: value })
|
||||
}
|
||||
placeholder={t('描述不想出现的内容')}
|
||||
rows={2}
|
||||
maxLength={1000}
|
||||
showClear
|
||||
/>
|
||||
</Form.Input>
|
||||
|
||||
{/* 分辨率 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('分辨率')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<Select
|
||||
value={formData.resolution}
|
||||
onChange={(value) =>
|
||||
setFormData({ ...formData, resolution: value })
|
||||
}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<Select.Option value='480P'>480P (832*480)</Select.Option>
|
||||
<Select.Option value='720P'>720P (1280*720)</Select.Option>
|
||||
<Select.Option value='1080P'>1080P (1920*1080)</Select.Option>
|
||||
</Select>
|
||||
</Form.Input>
|
||||
|
||||
{/* 时长 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('视频时长')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<InputNumber
|
||||
value={formData.duration}
|
||||
onChange={(value) => setFormData({ ...formData, duration: value })}
|
||||
min={3}
|
||||
max={10}
|
||||
suffix={t('秒')}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</Form.Input>
|
||||
|
||||
{/* 宽高比 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('宽高比')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<Select
|
||||
value={formData.ratio}
|
||||
onChange={(value) => setFormData({ ...formData, ratio: value })}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<Select.Option value='16:9'>{t('16:9 (横屏)')}</Select.Option>
|
||||
<Select.Option value='9:16'>{t('9:16 (竖屏)')}</Select.Option>
|
||||
<Select.Option value='1:1'>{t('1:1 (方形)')}</Select.Option>
|
||||
</Select>
|
||||
</Form.Input>
|
||||
|
||||
{/* 高级选项 */}
|
||||
<Form.Label>
|
||||
<Text strong>{t('高级选项')}</Text>
|
||||
</Form.Label>
|
||||
<Form.Input>
|
||||
<Space vertical align='start' style={{ width: '100%' }}>
|
||||
<Space>
|
||||
<Switch
|
||||
checked={formData.audio}
|
||||
onChange={(checked) =>
|
||||
setFormData({ ...formData, audio: checked })
|
||||
}
|
||||
/>
|
||||
<Text>{t('生成音频')}</Text>
|
||||
</Space>
|
||||
<Space>
|
||||
<Switch
|
||||
checked={formData.prompt_extend}
|
||||
onChange={(checked) =>
|
||||
setFormData({ ...formData, prompt_extend: checked })
|
||||
}
|
||||
/>
|
||||
<Text>{t('提示词扩展')}</Text>
|
||||
</Space>
|
||||
<Space>
|
||||
<InputNumber
|
||||
value={formData.seed}
|
||||
onChange={(value) => setFormData({ ...formData, seed: value })}
|
||||
placeholder={t('随机种子(可选)')}
|
||||
min={0}
|
||||
style={{ width: '100%', maxWidth: 200 }}
|
||||
/>
|
||||
<Text type='tertiary'>{t('固定种子可复现结果')}</Text>
|
||||
</Space>
|
||||
</Space>
|
||||
</Form.Input>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoRegenerateModal;
|
||||
@@ -0,0 +1,483 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Table,
|
||||
Button,
|
||||
Space,
|
||||
Tag,
|
||||
Progress,
|
||||
Tooltip,
|
||||
Modal,
|
||||
Badge,
|
||||
Select,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import {
|
||||
ChevronUp,
|
||||
ChevronDown,
|
||||
RefreshCw,
|
||||
Download,
|
||||
Trash2,
|
||||
Play,
|
||||
CheckCircle2,
|
||||
AlertCircle,
|
||||
Clock,
|
||||
Loader2,
|
||||
} from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useIsMobile } from '../../../../../hooks/common/useIsMobile';
|
||||
import {
|
||||
canRegenerateVideoTask,
|
||||
normalizeVideoTaskStatus,
|
||||
} from '../../../../../helpers/videoTask';
|
||||
|
||||
const VideoTaskQueue = ({
|
||||
visible,
|
||||
setVisible,
|
||||
tasks,
|
||||
onRefresh,
|
||||
onDelete,
|
||||
onDownload,
|
||||
onPlay, // 新增:播放回调
|
||||
onRegenerate, // 新增:再生成回调
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
// 断点判定必须按「宽度」。本组件此前 20 多处响应式判断写的是 !isCompact,
|
||||
// 判的是窗口高度——390x844 的手机上 844 > 768 成立,于是整个队列走桌面分支:
|
||||
// 8 列合计 1190px 塞进 ~340px 容器、按钮全带文字,实际完全用不了。
|
||||
const isCompact = useIsMobile();
|
||||
const [selectedTasks, setSelectedTasks] = useState([]);
|
||||
const [windowHeight, setWindowHeight] = useState(window.innerHeight);
|
||||
const [pageSize, setPageSize] = useState(5); // 新增:分页大小状态
|
||||
|
||||
// 监听窗口高度变化
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
setWindowHeight(window.innerHeight);
|
||||
};
|
||||
|
||||
window.addEventListener('resize', handleResize);
|
||||
return () => window.removeEventListener('resize', handleResize);
|
||||
}, []);
|
||||
|
||||
// 计算任务队列高度:不超过屏幕高度的20%(五分之一)
|
||||
// 同时设置最小高度150px,最大高度300px
|
||||
const getQueueHeight = () => {
|
||||
const maxHeightPercent = windowHeight * 0.2; // 屏幕高度的20%
|
||||
// 手机端工具栏本身会换行占掉 ~100px,再按 20%(844px 屏上仅 169px)会让表格只剩
|
||||
// 不到 70px,连表头带分页都放不下。窄屏改用更宽松的下限。
|
||||
const minHeight = isCompact ? 300 : 150;
|
||||
const maxHeight = isCompact ? 420 : 300;
|
||||
|
||||
// 在最小和最大值之间取适当的高度
|
||||
return Math.max(minHeight, Math.min(maxHeightPercent, maxHeight));
|
||||
};
|
||||
|
||||
const queueHeight = getQueueHeight();
|
||||
|
||||
// 状态标签映射
|
||||
const getStatusTag = (status) => {
|
||||
// 统一转换为小写进行比较
|
||||
const normalizedStatus = normalizeVideoTaskStatus(status);
|
||||
const statusMap = {
|
||||
queued: { color: 'blue', text: t('排队中'), icon: <Clock size={12} /> },
|
||||
in_progress: {
|
||||
color: 'cyan',
|
||||
text: t('生成中'),
|
||||
icon: <Loader2 size={12} className='animate-spin' />,
|
||||
},
|
||||
success: {
|
||||
color: 'green',
|
||||
text: t('已完成'),
|
||||
icon: <CheckCircle2 size={12} />,
|
||||
},
|
||||
completed: {
|
||||
color: 'green',
|
||||
text: t('已完成'),
|
||||
icon: <CheckCircle2 size={12} />,
|
||||
},
|
||||
failure: {
|
||||
color: 'red',
|
||||
text: t('失败'),
|
||||
icon: <AlertCircle size={12} />,
|
||||
},
|
||||
failed: {
|
||||
color: 'red',
|
||||
text: t('失败'),
|
||||
icon: <AlertCircle size={12} />,
|
||||
},
|
||||
canceled: {
|
||||
color: 'grey',
|
||||
text: t('已取消'),
|
||||
icon: <AlertCircle size={12} />,
|
||||
},
|
||||
};
|
||||
const config = statusMap[normalizedStatus] || {
|
||||
color: 'grey',
|
||||
text: status,
|
||||
};
|
||||
return (
|
||||
<Tag
|
||||
color={config.color}
|
||||
style={{ display: 'inline-flex', alignItems: 'center', gap: '4px' }}
|
||||
>
|
||||
{config.icon}
|
||||
{config.text}
|
||||
</Tag>
|
||||
);
|
||||
};
|
||||
|
||||
// 批量下载 - 只下载已完成的任务
|
||||
const handleBatchDownload = () => {
|
||||
selectedTasks.forEach((taskId) => {
|
||||
const task = tasks.find((t) => t.task_id === taskId);
|
||||
if (task) {
|
||||
const normalizedStatus = normalizeVideoTaskStatus(task.status);
|
||||
// 只下载已完成的任务,视频URL会在 onDownload 中获取
|
||||
if (normalizedStatus === 'success') {
|
||||
onDownload(task);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const handleBatchDelete = () => {
|
||||
selectedTasks.forEach((taskId) => {
|
||||
onDelete(taskId);
|
||||
});
|
||||
setSelectedTasks([]);
|
||||
};
|
||||
|
||||
// 表格列定义
|
||||
const columns = [
|
||||
{
|
||||
title: t('任务ID'),
|
||||
dataIndex: 'task_id',
|
||||
width: !isCompact ? 120 : 100,
|
||||
render: (text) => (
|
||||
<Tooltip content={text}>
|
||||
<span style={{ cursor: 'pointer' }}>{text?.substring(0, 8)}...</span>
|
||||
</Tooltip>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('模式'),
|
||||
dataIndex: 'action',
|
||||
width: !isCompact ? 100 : 80,
|
||||
render: (text) => {
|
||||
// action 字段存储的是 text2video 或 image2video
|
||||
const isText2Video = text === 'text2video' || text === 'TEXT2VIDEO';
|
||||
return (
|
||||
<Tag size={!isCompact ? 'default' : 'small'}>
|
||||
{isText2Video ? t('文生视频') : t('图生视频')}
|
||||
</Tag>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('模型'),
|
||||
dataIndex: 'model',
|
||||
width: !isCompact ? 150 : 120,
|
||||
render: (model) => model || '-',
|
||||
},
|
||||
{
|
||||
title: t('提示词'),
|
||||
dataIndex: 'prompt',
|
||||
width: !isCompact ? 200 : 150,
|
||||
ellipsis: { showTitle: true },
|
||||
render: (prompt) => prompt || '-',
|
||||
},
|
||||
{
|
||||
title: t('状态'),
|
||||
dataIndex: 'status',
|
||||
width: !isCompact ? 120 : 100,
|
||||
render: (status) => getStatusTag(status),
|
||||
},
|
||||
{
|
||||
title: t('进度'),
|
||||
dataIndex: 'progress',
|
||||
width: !isCompact ? 120 : 100,
|
||||
render: (progress, record) => {
|
||||
const normalizedStatus = normalizeVideoTaskStatus(record.status);
|
||||
if (normalizedStatus === 'success') return '100%';
|
||||
if (normalizedStatus === 'failure') return '-';
|
||||
// 去除百分号并转换为数字
|
||||
const percentValue =
|
||||
typeof progress === 'string'
|
||||
? parseInt(progress.replace('%', ''))
|
||||
: progress || 0;
|
||||
return <Progress percent={percentValue} showInfo size='small' />;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('创建时间'),
|
||||
dataIndex: 'created_at',
|
||||
width: !isCompact ? 160 : 140,
|
||||
render: (timestamp) => new Date(timestamp * 1000).toLocaleString('zh-CN'),
|
||||
},
|
||||
{
|
||||
title: t('操作'),
|
||||
dataIndex: 'operate',
|
||||
width: !isCompact ? 220 : 180,
|
||||
fixed: 'right',
|
||||
render: (text, record) => {
|
||||
const normalizedStatus = normalizeVideoTaskStatus(record.status);
|
||||
|
||||
return (
|
||||
<Space>
|
||||
{/* 播放和下载按钮:仅根据状态显示,视频URL在点击时才获取 */}
|
||||
{normalizedStatus === 'success' && (
|
||||
<>
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
icon={<Play size={14} />}
|
||||
onClick={() => onPlay && onPlay(record)}
|
||||
>
|
||||
{!isCompact ? t('播放') : ''}
|
||||
</Button>
|
||||
<Button
|
||||
size='small'
|
||||
type='tertiary'
|
||||
icon={<Download size={14} />}
|
||||
onClick={() => onDownload(record)}
|
||||
>
|
||||
{!isCompact ? t('下载') : ''}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{/* 再生成按钮 - 对所有已完成或失败的任务显示 */}
|
||||
{(normalizedStatus === 'success' ||
|
||||
normalizedStatus === 'failure') &&
|
||||
canRegenerateVideoTask(record) && (
|
||||
<Button
|
||||
size='small'
|
||||
type='primary'
|
||||
icon={<RefreshCw size={14} />}
|
||||
onClick={() => onRegenerate && onRegenerate(record)}
|
||||
>
|
||||
{!isCompact ? t('再生成') : ''}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
size='small'
|
||||
type='danger'
|
||||
icon={<Trash2 size={14} />}
|
||||
onClick={() => {
|
||||
Modal.warning({
|
||||
title: t('确定删除此任务?'),
|
||||
content: t('删除后将无法恢复'),
|
||||
icon: <AlertCircle size={24} style={{ color: '#f59e0b' }} />,
|
||||
okText: t('确定'),
|
||||
cancelText: t('取消'),
|
||||
onOk: () => onDelete(record.task_id),
|
||||
centered: true,
|
||||
okButtonProps: { type: 'danger' },
|
||||
});
|
||||
}}
|
||||
>
|
||||
{!isCompact ? t('删除') : ''}
|
||||
</Button>
|
||||
</Space>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
// 统计信息
|
||||
const taskStats = {
|
||||
total: tasks.length,
|
||||
queued: tasks.filter((t) => normalizeVideoTaskStatus(t.status) === 'queued')
|
||||
.length,
|
||||
in_progress: tasks.filter(
|
||||
(t) => normalizeVideoTaskStatus(t.status) === 'in_progress',
|
||||
).length,
|
||||
completed: tasks.filter((t) => {
|
||||
return normalizeVideoTaskStatus(t.status) === 'success';
|
||||
}).length,
|
||||
failed: tasks.filter((t) => {
|
||||
return normalizeVideoTaskStatus(t.status) === 'failure';
|
||||
}).length,
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* 折叠触发器 */}
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
bottom: visible ? `${queueHeight}px` : '0',
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: '40px',
|
||||
backgroundColor: 'var(--semi-color-bg-1)',
|
||||
borderTop: '1px solid var(--semi-color-border)',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
cursor: 'pointer',
|
||||
transition: 'bottom 0.3s',
|
||||
zIndex: 10,
|
||||
}}
|
||||
onClick={() => setVisible(!visible)}
|
||||
>
|
||||
<Space>
|
||||
{visible ? <ChevronDown size={16} /> : <ChevronUp size={16} />}
|
||||
<span style={{ fontSize: !isCompact ? '14px' : '12px' }}>
|
||||
{t('任务队列')} ({taskStats.total})
|
||||
</span>
|
||||
{taskStats.in_progress > 0 && (
|
||||
<Badge count={taskStats.in_progress} type='danger' />
|
||||
)}
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
{/* 任务队列抽屉 */}
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
bottom: visible ? '0' : `-${queueHeight}px`,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: `${queueHeight}px`,
|
||||
backgroundColor: 'var(--semi-color-bg-0)',
|
||||
borderTop: '1px solid var(--semi-color-border)',
|
||||
transition: 'bottom 0.3s',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
zIndex: 9,
|
||||
}}
|
||||
>
|
||||
{/* 工具栏 */}
|
||||
<div
|
||||
style={{
|
||||
padding: !isCompact ? '12px 16px' : '8px 12px',
|
||||
borderBottom: '1px solid var(--semi-color-border)',
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
flexWrap: 'wrap',
|
||||
gap: '8px',
|
||||
}}
|
||||
>
|
||||
<Space wrap>
|
||||
<Button
|
||||
size={!isCompact ? 'default' : 'small'}
|
||||
icon={<RefreshCw size={14} />}
|
||||
onClick={onRefresh}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
{selectedTasks.length > 0 && (
|
||||
<>
|
||||
<Button
|
||||
size={!isCompact ? 'default' : 'small'}
|
||||
icon={<Download size={14} />}
|
||||
onClick={handleBatchDownload}
|
||||
>
|
||||
{t('批量下载')} ({selectedTasks.length})
|
||||
</Button>
|
||||
<Button
|
||||
size={!isCompact ? 'default' : 'small'}
|
||||
type='danger'
|
||||
icon={<Trash2 size={14} />}
|
||||
onClick={() => {
|
||||
Modal.warning({
|
||||
title: t('确定删除选中的任务?'),
|
||||
content: t('将删除 {{count}} 个任务,删除后将无法恢复', {
|
||||
count: selectedTasks.length,
|
||||
}),
|
||||
icon: (
|
||||
<AlertCircle size={24} style={{ color: '#f59e0b' }} />
|
||||
),
|
||||
okText: t('确定删除'),
|
||||
cancelText: t('取消'),
|
||||
onOk: handleBatchDelete,
|
||||
centered: true,
|
||||
okButtonProps: { type: 'danger' },
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t('批量删除')} ({selectedTasks.length})
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</Space>
|
||||
|
||||
{/* 统计信息 */}
|
||||
<Space wrap>
|
||||
<Tag size={!isCompact ? 'default' : 'small'} color='blue'>
|
||||
{t('排队')}: {taskStats.queued}
|
||||
</Tag>
|
||||
<Tag size={!isCompact ? 'default' : 'small'} color='cyan'>
|
||||
{t('生成中')}: {taskStats.in_progress}
|
||||
</Tag>
|
||||
<Tag size={!isCompact ? 'default' : 'small'} color='green'>
|
||||
{t('完成')}: {taskStats.completed}
|
||||
</Tag>
|
||||
<Tag size={!isCompact ? 'default' : 'small'} color='red'>
|
||||
{t('失败')}: {taskStats.failed}
|
||||
</Tag>
|
||||
{/* 分页大小选择器 */}
|
||||
<Select
|
||||
size={!isCompact ? 'default' : 'small'}
|
||||
value={pageSize}
|
||||
onChange={setPageSize}
|
||||
style={{ width: !isCompact ? '120px' : '100px' }}
|
||||
>
|
||||
<Select.Option value={3}>3 {t('条/页')}</Select.Option>
|
||||
<Select.Option value={5}>5 {t('条/页')}</Select.Option>
|
||||
<Select.Option value={10}>10 {t('条/页')}</Select.Option>
|
||||
<Select.Option value={20}>20 {t('条/页')}</Select.Option>
|
||||
<Select.Option value={50}>50 {t('条/页')}</Select.Option>
|
||||
</Select>
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
{/* 任务表格 */}
|
||||
<div style={{ flex: 1, overflow: 'auto' }}>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={tasks}
|
||||
rowKey='task_id'
|
||||
scroll={{ x: 'max-content' }}
|
||||
pagination={{
|
||||
pageSize: pageSize,
|
||||
showSizeChanger: false,
|
||||
size: !isCompact ? 'default' : 'small',
|
||||
}}
|
||||
rowSelection={{
|
||||
selectedRowKeys: selectedTasks,
|
||||
onChange: setSelectedTasks,
|
||||
getCheckboxProps: (record) => ({
|
||||
disabled: record.status === 'in_progress',
|
||||
}),
|
||||
}}
|
||||
size='small'
|
||||
empty={t('暂无任务')}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoTaskQueue;
|
||||
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import VideoInputPanel from './Video/VideoInputPanel';
|
||||
import VideoPreviewPanel from './Video/VideoPreviewPanel';
|
||||
import VideoTaskQueue from './Video/VideoTaskQueue';
|
||||
import VideoRegenerateModal from './Video/VideoRegenerateModal';
|
||||
import { useVideoGeneration } from '../../../../hooks/video/useVideoGeneration';
|
||||
|
||||
const VideoGenerationTab = () => {
|
||||
const [leftPanelCollapsed, setLeftPanelCollapsed] = useState(false);
|
||||
const [taskQueueVisible, setTaskQueueVisible] = useState(false);
|
||||
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
|
||||
const [selectedTaskForPlay, setSelectedTaskForPlay] = useState(null);
|
||||
const [regenerateModalVisible, setRegenerateModalVisible] = useState(false);
|
||||
const [taskToRegenerate, setTaskToRegenerate] = useState(null);
|
||||
|
||||
// 监听窗口大小变化
|
||||
useEffect(() => {
|
||||
const handleResize = () => {
|
||||
setWindowWidth(window.innerWidth);
|
||||
};
|
||||
|
||||
window.addEventListener('resize', handleResize);
|
||||
return () => window.removeEventListener('resize', handleResize);
|
||||
}, []);
|
||||
|
||||
const {
|
||||
// 表单数据
|
||||
formData,
|
||||
setFormData,
|
||||
// 模型相关
|
||||
selectedModel,
|
||||
setSelectedModel,
|
||||
modelInfo,
|
||||
// 生成相关
|
||||
generating,
|
||||
currentTask,
|
||||
handleGenerate,
|
||||
submitVideo,
|
||||
handleCancel,
|
||||
// 任务列表
|
||||
tasks,
|
||||
refreshTasks,
|
||||
deleteTask,
|
||||
getRegenerationTask,
|
||||
downloadTask,
|
||||
getTaskVideoUrl,
|
||||
} = useVideoGeneration();
|
||||
|
||||
// 处理任务列表的播放按钮
|
||||
const handlePlayTask = async (task) => {
|
||||
// 获取最新的预签名URL
|
||||
const videoUrl = await getTaskVideoUrl(task.task_id);
|
||||
if (videoUrl) {
|
||||
// 更新 task 对象中的 video_url
|
||||
const updatedTask = { ...task };
|
||||
// 解析或初始化 data 对象
|
||||
let data = {};
|
||||
if (updatedTask.data) {
|
||||
try {
|
||||
data =
|
||||
typeof updatedTask.data === 'string'
|
||||
? JSON.parse(updatedTask.data)
|
||||
: { ...updatedTask.data };
|
||||
} catch (e) {
|
||||
console.error('Failed to parse task data:', e);
|
||||
}
|
||||
}
|
||||
// 设置 video_url
|
||||
data.video_url = videoUrl;
|
||||
updatedTask.data = data;
|
||||
setSelectedTaskForPlay(updatedTask);
|
||||
} else {
|
||||
setSelectedTaskForPlay(task);
|
||||
}
|
||||
};
|
||||
|
||||
// 处理关闭视频播放(清除选中的任务)
|
||||
const handleClearSelectedTask = () => {
|
||||
setSelectedTaskForPlay(null);
|
||||
};
|
||||
|
||||
// 处理再生成按钮
|
||||
const handleRegenerate = async (task) => {
|
||||
const detail = await getRegenerationTask(task.task_id);
|
||||
if (!detail) return;
|
||||
setTaskToRegenerate(detail);
|
||||
setRegenerateModalVisible(true);
|
||||
};
|
||||
|
||||
// 确认再生成
|
||||
const handleRegenerateConfirm = async (requestData) => {
|
||||
const submitted = await submitVideo(requestData, requestData.model);
|
||||
if (submitted) {
|
||||
setRegenerateModalVisible(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 响应式布局配置 - 两列布局(左侧配置区 + 右侧预览区)
|
||||
const getLayoutConfig = () => {
|
||||
// 超大屏幕 (>1920px): 25% - 75%
|
||||
if (windowWidth > 1920) {
|
||||
return {
|
||||
leftWidth: '25%',
|
||||
centerWidth: '75%',
|
||||
minLeftWidth: '350px',
|
||||
minCenterWidth: '800px',
|
||||
direction: 'row',
|
||||
};
|
||||
}
|
||||
// 大屏幕 (1600-1920px): 28% - 72%
|
||||
if (windowWidth > 1600) {
|
||||
return {
|
||||
leftWidth: '28%',
|
||||
centerWidth: '72%',
|
||||
minLeftWidth: '320px',
|
||||
minCenterWidth: '700px',
|
||||
direction: 'row',
|
||||
};
|
||||
}
|
||||
// 中等屏幕 (1280-1600px): 32% - 68%
|
||||
if (windowWidth > 1280) {
|
||||
return {
|
||||
leftWidth: '32%',
|
||||
centerWidth: '68%',
|
||||
minLeftWidth: '300px',
|
||||
minCenterWidth: '600px',
|
||||
direction: 'row',
|
||||
};
|
||||
}
|
||||
// 小屏幕 (1024-1280px): 35% - 65%
|
||||
if (windowWidth > 1024) {
|
||||
return {
|
||||
leftWidth: '35%',
|
||||
centerWidth: '65%',
|
||||
minLeftWidth: '280px',
|
||||
minCenterWidth: '500px',
|
||||
direction: 'row',
|
||||
};
|
||||
}
|
||||
// 超小屏幕 (<1024px): 单列布局
|
||||
return {
|
||||
leftWidth: '100%',
|
||||
centerWidth: '100%',
|
||||
minLeftWidth: '100%',
|
||||
minCenterWidth: '100%',
|
||||
direction: 'column',
|
||||
};
|
||||
};
|
||||
|
||||
const layoutConfig = getLayoutConfig();
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
position: 'relative',
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
flex: 1,
|
||||
overflow: layoutConfig.direction === 'row' ? 'hidden' : 'auto',
|
||||
display: 'flex',
|
||||
flexDirection: layoutConfig.direction === 'row' ? 'row' : 'column',
|
||||
gap: layoutConfig.direction === 'column' ? '16px' : '0',
|
||||
position: 'relative',
|
||||
paddingBottom: '40px', // 为任务队列触发器留出空间
|
||||
}}
|
||||
>
|
||||
{/* 左侧:输入区域(区域1) */}
|
||||
<div
|
||||
style={{
|
||||
width:
|
||||
layoutConfig.direction === 'row'
|
||||
? layoutConfig.leftWidth
|
||||
: '100%',
|
||||
minWidth: layoutConfig.minLeftWidth,
|
||||
height: layoutConfig.direction === 'row' ? '100%' : 'auto',
|
||||
// 折叠态不能再预留 500px:面板收起后只剩一个 fixed 定位的浮动箭头,
|
||||
// 这 500px 会变成页面顶部一整块空白
|
||||
minHeight:
|
||||
layoutConfig.direction === 'column' && !leftPanelCollapsed
|
||||
? '500px'
|
||||
: 'auto',
|
||||
flexShrink: layoutConfig.direction === 'row' ? 0 : 1,
|
||||
backgroundColor: 'var(--semi-color-bg-1)',
|
||||
borderRight:
|
||||
layoutConfig.direction === 'row'
|
||||
? '1px solid var(--semi-color-border)'
|
||||
: 'none',
|
||||
borderBottom:
|
||||
layoutConfig.direction === 'column'
|
||||
? '1px solid var(--semi-color-border)'
|
||||
: 'none',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className='app-scrollbar'
|
||||
style={{
|
||||
height: '100%',
|
||||
overflow: 'auto',
|
||||
paddingBottom: layoutConfig.direction === 'row' ? '16px' : '16px',
|
||||
}}
|
||||
>
|
||||
<VideoInputPanel
|
||||
formData={formData}
|
||||
setFormData={setFormData}
|
||||
onCollapse={() => setLeftPanelCollapsed(!leftPanelCollapsed)}
|
||||
collapsed={leftPanelCollapsed}
|
||||
collapsible={layoutConfig.direction === 'row'}
|
||||
selectedModel={selectedModel}
|
||||
setSelectedModel={setSelectedModel}
|
||||
modelInfo={modelInfo}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 右侧:预览+生成区域 */}
|
||||
<div
|
||||
style={{
|
||||
flex: 1,
|
||||
height: layoutConfig.direction === 'row' ? '100%' : 'auto',
|
||||
minHeight: layoutConfig.direction === 'column' ? '600px' : 'auto',
|
||||
minWidth: 0,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className='app-scrollbar'
|
||||
style={{
|
||||
height: '100%',
|
||||
backgroundColor: 'var(--semi-color-bg-0)',
|
||||
padding: windowWidth > 768 ? '16px' : '12px',
|
||||
overflow: 'auto',
|
||||
}}
|
||||
>
|
||||
<VideoPreviewPanel
|
||||
formData={formData}
|
||||
generating={generating}
|
||||
currentTask={currentTask}
|
||||
onGenerate={handleGenerate}
|
||||
onCancel={handleCancel}
|
||||
selectedModel={selectedModel}
|
||||
selectedTaskForPlay={selectedTaskForPlay}
|
||||
onRegenerate={handleRegenerate}
|
||||
onClearSelectedTask={handleClearSelectedTask}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 底部:任务队列(区域4) - 使用 absolute 定位,相对于父容器 */}
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
zIndex: 1000,
|
||||
}}
|
||||
>
|
||||
<VideoTaskQueue
|
||||
visible={taskQueueVisible}
|
||||
setVisible={setTaskQueueVisible}
|
||||
tasks={tasks}
|
||||
onRefresh={refreshTasks}
|
||||
onDelete={deleteTask}
|
||||
onDownload={downloadTask}
|
||||
onPlay={handlePlayTask}
|
||||
onRegenerate={handleRegenerate}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 再生成弹窗 */}
|
||||
<VideoRegenerateModal
|
||||
visible={regenerateModalVisible}
|
||||
onCancel={() => setRegenerateModalVisible(false)}
|
||||
onConfirm={handleRegenerateConfirm}
|
||||
task={taskToRegenerate}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoGenerationTab;
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Card, Empty } from '@douyinfe/semi-ui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { IllustrationConstruction } from '../../../../components/common/illustrations';
|
||||
|
||||
const VideoRemixTab = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<Empty
|
||||
image={<IllustrationConstruction style={{ width: 150, height: 150 }} />}
|
||||
title={t('视频 Remix')}
|
||||
description={t('此功能正在开发中,敬请期待')}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoRemixTab;
|
||||
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, { useMemo, useState, useEffect } from 'react';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
BrainCircuit,
|
||||
Image,
|
||||
Video,
|
||||
Sparkles,
|
||||
} from 'lucide-react';
|
||||
import { useSidebarCollapsed } from '../../../hooks/common/useSidebarCollapsed';
|
||||
import { useExperienceModules } from '../useExperienceModules';
|
||||
|
||||
const ExperienceSidebar = () => {
|
||||
const { t } = useTranslation();
|
||||
const [collapsed, toggleCollapsed] = useSidebarCollapsed();
|
||||
const [selectedKeys, setSelectedKeys] = useState([]);
|
||||
const location = useLocation();
|
||||
const { isAvailable } = useExperienceModules();
|
||||
|
||||
// 统一单一品牌色高亮(云平台风格),不再每项一种颜色
|
||||
const allNavItems = useMemo(
|
||||
() => [
|
||||
{
|
||||
text: t('云端大脑'),
|
||||
itemKey: 'cloud-brain',
|
||||
configKey: 'cloudBrain',
|
||||
to: '/experience-center/cloud-brain',
|
||||
icon: BrainCircuit,
|
||||
beta: true,
|
||||
},
|
||||
{
|
||||
text: t('图片生成'),
|
||||
itemKey: 'image-generation',
|
||||
configKey: 'imageGeneration',
|
||||
to: '/experience-center/image-generation',
|
||||
icon: Image,
|
||||
},
|
||||
{
|
||||
text: t('视频生成'),
|
||||
itemKey: 'video-generation',
|
||||
configKey: 'videoGeneration',
|
||||
to: '/experience-center/video-generation',
|
||||
icon: Video,
|
||||
},
|
||||
],
|
||||
[t],
|
||||
);
|
||||
|
||||
// 根据配置过滤导航项(与默认落地页共用 useExperienceModules 判定)
|
||||
const navItems = useMemo(
|
||||
() => allNavItems.filter((item) => isAvailable(item.configKey)),
|
||||
[allNavItems, isAvailable],
|
||||
);
|
||||
|
||||
// 根据当前路径设置选中的菜单项
|
||||
useEffect(() => {
|
||||
const currentPath = location.pathname;
|
||||
const matchingItem = navItems.find((item) =>
|
||||
currentPath.startsWith(item.to),
|
||||
);
|
||||
|
||||
if (matchingItem) {
|
||||
setSelectedKeys([matchingItem.itemKey]);
|
||||
}
|
||||
}, [location.pathname, navItems]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`
|
||||
relative flex flex-col h-full transition-all duration-300 ease-out
|
||||
bg-white/60 dark:bg-neutral-900/60 backdrop-blur-2xl backdrop-saturate-[1.8]
|
||||
border-r border-white/40 dark:border-neutral-700/50
|
||||
shadow-[1px_0_24px_-4px_rgba(0,0,0,0.06)] dark:shadow-[1px_0_24px_-4px_rgba(0,0,0,0.3)]
|
||||
${collapsed ? 'w-[68px]' : 'w-[240px]'}
|
||||
`}
|
||||
>
|
||||
{/* 毛玻璃内层光泽 */}
|
||||
<div className='absolute inset-0 bg-gradient-to-b from-white/40 via-white/10 to-white/20 dark:from-white/[0.06] dark:via-transparent dark:to-white/[0.03] pointer-events-none' />
|
||||
{/* 顶部装饰渐变 —— /8 /3 步进 Tailwind 不生成,改用 /10 两 stop 确保可见 */}
|
||||
<div className='absolute top-0 left-0 right-0 h-32 bg-gradient-to-b from-brand-from/10 to-transparent pointer-events-none' />
|
||||
|
||||
{/* Logo/标题区域 */}
|
||||
{!collapsed && (
|
||||
<div className='px-4 pt-5 pb-3'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<div className='p-1.5 bg-gradient-to-br from-brand-from to-brand-to rounded-lg'>
|
||||
<Sparkles size={16} className='text-white' />
|
||||
</div>
|
||||
<span className='font-bold text-gray-900 dark:text-white'>
|
||||
{t('体验中心')}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 导航区域 */}
|
||||
<nav
|
||||
className={`relative flex-1 px-3 ${collapsed ? 'pt-4' : 'pt-2'} space-y-1.5 overflow-y-auto overflow-x-hidden`}
|
||||
>
|
||||
{navItems.map((item) => {
|
||||
const isSelected = selectedKeys.includes(item.itemKey);
|
||||
const IconComponent = item.icon;
|
||||
|
||||
return (
|
||||
<Link
|
||||
key={item.itemKey}
|
||||
to={item.to}
|
||||
onClick={() => setSelectedKeys([item.itemKey])}
|
||||
className={`
|
||||
group relative flex items-center gap-3 rounded-xl transition-all duration-200
|
||||
${collapsed ? 'justify-center p-3' : 'px-3 py-2.5'}
|
||||
${
|
||||
isSelected
|
||||
? 'bg-brand/10 dark:bg-brand/15 shadow-sm shadow-brand/5'
|
||||
: 'hover:bg-brand/5 dark:hover:bg-brand/10'
|
||||
}
|
||||
`}
|
||||
>
|
||||
{/* 选中指示器 —— 统一品牌色 */}
|
||||
{isSelected && (
|
||||
<div className='absolute left-0 top-1/2 -translate-y-1/2 w-1 h-6 rounded-r-full bg-gradient-to-b from-brand-from to-brand-to' />
|
||||
)}
|
||||
|
||||
{/* 图标 —— 激活:品牌渐变实底;非激活:中性,hover 转品牌 */}
|
||||
<div
|
||||
className={`
|
||||
relative flex-shrink-0 p-1.5 rounded-lg transition-all duration-200
|
||||
${
|
||||
isSelected
|
||||
? 'bg-gradient-to-br from-brand-from to-brand-to shadow-lg shadow-brand/25'
|
||||
: 'bg-gray-100/80 dark:bg-neutral-800/80 group-hover:bg-brand/10 group-hover:scale-105'
|
||||
}
|
||||
`}
|
||||
>
|
||||
<IconComponent
|
||||
size={18}
|
||||
strokeWidth={2}
|
||||
className={
|
||||
isSelected
|
||||
? 'text-white'
|
||||
: 'text-gray-500 dark:text-gray-400 group-hover:text-brand-deep dark:group-hover:text-brand-from transition-colors'
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 文字 */}
|
||||
{!collapsed && (
|
||||
<span className='flex min-w-0 items-center gap-2'>
|
||||
<span
|
||||
className={`
|
||||
text-sm transition-colors truncate
|
||||
${
|
||||
isSelected
|
||||
? 'text-brand-deep dark:text-brand-from font-semibold'
|
||||
: 'font-medium text-gray-600 dark:text-gray-300 group-hover:text-brand-deep dark:group-hover:text-brand-from'
|
||||
}
|
||||
`}
|
||||
>
|
||||
{item.text}
|
||||
</span>
|
||||
{item.beta && (
|
||||
<span className='shrink-0 rounded-full border border-orange-300/70 bg-orange-50 px-1.5 py-0.5 font-mono text-[8px] font-bold tracking-wider text-orange-700'>
|
||||
BETA
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
|
||||
{/* Tooltip for collapsed state */}
|
||||
{collapsed && (
|
||||
<div
|
||||
className='
|
||||
absolute left-full ml-2 px-2.5 py-1.5
|
||||
bg-gray-900 dark:bg-white text-white dark:text-gray-900
|
||||
text-xs font-medium rounded-lg shadow-lg
|
||||
opacity-0 invisible group-hover:opacity-100 group-hover:visible
|
||||
transition-all duration-200 whitespace-nowrap z-50
|
||||
'
|
||||
>
|
||||
{item.text}
|
||||
<div
|
||||
className='absolute left-0 top-1/2 -translate-x-1 -translate-y-1/2
|
||||
border-4 border-transparent border-r-gray-900 dark:border-r-white'
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
|
||||
{/* 底部分隔线装饰 */}
|
||||
<div className='mx-4 h-px bg-gradient-to-r from-transparent via-gray-200/60 dark:via-neutral-700/60 to-transparent' />
|
||||
|
||||
{/* 底部折叠按钮 */}
|
||||
<div className='relative p-3'>
|
||||
<button
|
||||
onClick={toggleCollapsed}
|
||||
className={`
|
||||
flex items-center justify-center gap-2 w-full py-2 rounded-lg
|
||||
text-gray-500 dark:text-gray-400 text-sm font-medium
|
||||
bg-white/50 dark:bg-neutral-800/50
|
||||
border border-gray-200/40 dark:border-neutral-700/40
|
||||
hover:bg-brand/10 dark:hover:bg-brand/15
|
||||
hover:text-brand-deep dark:hover:text-brand-from
|
||||
hover:border-brand/30
|
||||
transition-all duration-200
|
||||
${collapsed ? 'px-2' : 'px-3'}
|
||||
`}
|
||||
>
|
||||
{collapsed ? (
|
||||
<ChevronRight size={16} strokeWidth={2.5} />
|
||||
) : (
|
||||
<>
|
||||
<ChevronLeft size={16} strokeWidth={2.5} />
|
||||
<span>{t('收起')}</span>
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ExperienceSidebar;
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import ImageGenerationTab from './AICreation/ImageGenerationTab';
|
||||
|
||||
const ImageGeneration = () => {
|
||||
return (
|
||||
<div className='h-full min-h-0'>
|
||||
<ImageGenerationTab />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ImageGeneration;
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import Token from '../../Token';
|
||||
|
||||
const KeyManagement = () => {
|
||||
return <Token />;
|
||||
};
|
||||
|
||||
export default KeyManagement;
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import Playground from '../../Playground';
|
||||
|
||||
const TextModel = () => {
|
||||
return (
|
||||
<div className='experience-text-model h-full relative overflow-hidden'>
|
||||
{/* 动态背景层 */}
|
||||
<div className='absolute inset-0 pointer-events-none'>
|
||||
{/* 渐变背景 —— 角落晕染走 bg-glow-to。
|
||||
* 透明度刻意高于 UserCenter (/20) —— 本页 ChatArea 有 bg-white/60 毛玻璃
|
||||
* 容器几乎全屏遮罩,再叠底部 from-white/30 装饰条,右下角实际可见 alpha
|
||||
* 会被双层 overlay 削到 ~7% 几乎不可见。/50 light 下穿透两层后 ~14% 才有
|
||||
* 与其他页面同水平的视觉强度。结构特例,不强行与 UserCenter 对齐刻度。 */}
|
||||
<div className='absolute inset-0 bg-gradient-to-b from-slate-50 via-white to-bg-glow-to/50 dark:from-[#0a0a0f] dark:via-[#0f0f18] dark:to-bg-glow-to/20' />
|
||||
|
||||
{/* 动态光球 —— 三个 blob 走 bg-glow-from / to 两 stop */}
|
||||
<div className='absolute top-[5%] right-[10%] w-[400px] h-[400px] rounded-full bg-gradient-to-br from-bg-glow-from/15 to-bg-glow-to/15 dark:from-bg-glow-from/10 dark:to-bg-glow-to/10 blur-[100px] animate-pulse' />
|
||||
<div
|
||||
className='absolute bottom-[10%] left-[5%] w-[350px] h-[350px] rounded-full bg-gradient-to-br from-bg-glow-from/15 to-bg-glow-to/15 dark:from-bg-glow-from/10 dark:to-bg-glow-to/10 blur-[100px] animate-pulse'
|
||||
style={{ animationDelay: '1.5s' }}
|
||||
/>
|
||||
<div
|
||||
className='absolute top-[40%] left-[30%] w-[250px] h-[250px] rounded-full bg-gradient-to-br from-bg-glow-from/10 to-bg-glow-to/10 dark:from-bg-glow-from/5 dark:to-bg-glow-to/5 blur-[80px] animate-pulse'
|
||||
style={{ animationDelay: '3s' }}
|
||||
/>
|
||||
|
||||
{/* 装饰性网格 —— 与全页背景统一走 bg-glow-* CSS 变量 */}
|
||||
<div
|
||||
className='absolute inset-0 opacity-[0.02] dark:opacity-[0.04]'
|
||||
style={{
|
||||
backgroundImage: `
|
||||
radial-gradient(circle at 25% 25%, color-mix(in srgb, var(--bg-glow-from) 30%, transparent) 0%, transparent 50%),
|
||||
radial-gradient(circle at 75% 75%, color-mix(in srgb, var(--bg-glow-to) 30%, transparent) 0%, transparent 50%)
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* 顶部装饰线 */}
|
||||
<div className='absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-transparent via-brand-via/30 to-transparent' />
|
||||
</div>
|
||||
|
||||
{/* 内容区域 */}
|
||||
<div className='relative z-10 h-full pb-2'>
|
||||
<Playground isExperienceMode={true} />
|
||||
</div>
|
||||
|
||||
{/* 底部装饰 - z-index 低于内容区域,避免遮挡输入框 */}
|
||||
<div className='absolute bottom-0 left-0 right-0 h-16 bg-gradient-to-t from-white/30 dark:from-neutral-950/30 to-transparent pointer-events-none z-[5]' />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default TextModel;
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Video, Sparkles, Clapperboard, Film, Play } from 'lucide-react';
|
||||
import VideoGenerationTab from './AICreation/VideoGenerationTab';
|
||||
|
||||
const VideoGeneration = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<div className='h-full flex flex-col p-6 relative overflow-hidden'>
|
||||
{/* 背景由父级 ExperienceCenter 的 PageBackground(rich) 统一提供,此处不再渲染 */}
|
||||
|
||||
{/* Header */}
|
||||
<div className='relative z-10 flex-shrink-0 mb-6'>
|
||||
<div className='flex items-center gap-4'>
|
||||
{/* 图标容器 */}
|
||||
<div className='relative'>
|
||||
<div className='absolute -inset-2 bg-gradient-to-r from-cyan-500/30 to-blue-500/30 rounded-2xl blur-lg opacity-60' />
|
||||
<div className='relative p-3 bg-gradient-to-br from-cyan-500 via-blue-500 to-brand-to rounded-2xl shadow-xl shadow-cyan-500/30'>
|
||||
<Video size={26} className='text-white' />
|
||||
</div>
|
||||
<Sparkles
|
||||
size={16}
|
||||
className='absolute -top-1 -right-1 text-amber-400 animate-pulse'
|
||||
/>
|
||||
|
||||
{/* 播放动画指示器 */}
|
||||
<div className='absolute -bottom-1 -left-1 w-5 h-5 rounded-full bg-green-500 flex items-center justify-center shadow-lg shadow-green-500/50'>
|
||||
<Play size={10} className='text-white ml-0.5' fill='white' />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 标题文字 */}
|
||||
<div>
|
||||
<h1 className='text-2xl md:text-3xl font-bold flex items-center gap-2'>
|
||||
<span className='bg-clip-text text-transparent bg-gradient-to-r from-cyan-600 via-blue-600 to-brand-to dark:from-cyan-400 dark:via-blue-400 dark:to-brand-to'>
|
||||
{t('视频生成')}
|
||||
</span>
|
||||
</h1>
|
||||
<p className='text-sm text-gray-500 dark:text-gray-400 mt-1'>
|
||||
{t('使用 AI 创建令人惊叹的视频内容')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 右侧装饰标签 */}
|
||||
<div className='hidden md:flex items-center gap-2 ml-auto'>
|
||||
<div className='flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-gradient-to-r from-cyan-50 to-teal-50 dark:from-cyan-950/30 dark:to-teal-950/30 border border-cyan-200/50 dark:border-cyan-800/30'>
|
||||
<Clapperboard size={14} className='text-cyan-500' />
|
||||
<span className='text-xs font-medium text-cyan-600 dark:text-cyan-400'>
|
||||
{t('图生视频')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-gradient-to-r from-blue-50 to-brand-to/5 dark:from-blue-950/30 dark:to-brand-to/30 border border-blue-200/50 dark:border-blue-800/30'>
|
||||
<Film size={14} className='text-blue-500' />
|
||||
<span className='text-xs font-medium text-blue-600 dark:text-blue-400'>
|
||||
{t('文生视频')}
|
||||
</span>
|
||||
</div>
|
||||
<div className='flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-gradient-to-r from-brand-from/5 to-brand-to/5 dark:from-brand-from/30 dark:to-brand-to/30 border border-brand/50 dark:border-brand-deep/30'>
|
||||
<Sparkles size={14} className='text-brand' />
|
||||
<span className='text-xs font-medium text-brand-deep dark:text-brand-from'>
|
||||
{t('多模型支持')}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Content */}
|
||||
<div className='relative z-10 flex-1 min-h-0'>
|
||||
{/* 卡片装饰边框 */}
|
||||
<div className='absolute -inset-0.5 bg-gradient-to-r from-cyan-500/20 via-blue-500/20 to-brand-to/20 rounded-[20px] blur-sm opacity-60' />
|
||||
|
||||
{/* 内容卡片 */}
|
||||
<div className='relative h-full bg-white/70 dark:bg-neutral-900/70 backdrop-blur-xl rounded-2xl border border-white/50 dark:border-neutral-800/50 shadow-xl shadow-cyan-500/5 overflow-hidden'>
|
||||
{/* 顶部装饰线 */}
|
||||
<div className='absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-transparent via-cyan-500/50 to-transparent' />
|
||||
|
||||
{/* 左侧装饰线 */}
|
||||
<div className='absolute top-0 bottom-0 left-0 w-[2px] bg-gradient-to-b from-transparent via-blue-500/30 to-transparent' />
|
||||
|
||||
<VideoGenerationTab />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default VideoGeneration;
|
||||
Reference in New Issue
Block a user