945 lines
33 KiB
React
945 lines
33 KiB
React
/*
|
||
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;
|