/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import React 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 (
); } return (
{/* 背景装饰 —— 走 bg-glow-* 两 stop(from/to) */}
{/* 收起按钮 —— 仅在左右分栏布局下提供 */} {collapsible && (
)} {/* 生成方式 */}
{t('生成方式')}
} 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' }} >
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' && (
)}
{t('文生视频')}
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' && (
)}
{t('图生视频')}
{/* 模型选择 */}
{t('选择模型')}
} 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' }} > { setSelectedModel(model); }} placeholder={t('请选择模型')} /> {/* 模型信息简要展示 */} {modelInfo && (
{t('厂商')} {modelInfo.provider}
{Number(modelInfo.price) > 0 && (
{t('单价')} {convertUSDToCurrency(Number(modelInfo.price || 0), 6)}
)}
)}
{/* 场景模板 */}
{t('场景模板')}
} 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' }} > {formData.selectedTemplate && (
{t('模板内容')}: {formData.selectedTemplate}
)}
{/* 提示词 */}
{t('提示词')}
} 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' }} >