Files
monkey-ai-web/src/pages/ExperienceCenter/components/AICreation/Video/VideoModelPanel.jsx
T
zhanjunhao 8a48765a46 chore(repo): 移除重复版权文件头并纳入共享单测
集中保留原版权声明,移除文件头检查和全局测试忽略规则。验证:全量单测、受影响用例复测及静态检查通过。
2026-11-20 11:23:49 +08:00

133 lines
4.0 KiB
React

import React, { useEffect } from 'react';
import { Card, Typography, Space, Tag } from '@/components/ui';
import { IconCreditCard, IconTickCircle } from '@/components/ui/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' }}
styles={{ body: { 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' }}
styles={{ body: { 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>
}
styles={{ body: { padding: '12px' } }}
>
<div
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<Text type='tertiary'>{t('单价')}</Text>
<Text
strong
style={{ fontSize: '18px', color: 'var(--ui-color-primary)' }}
>
{convertUSDToCurrency(Number(modelInfo?.price || 0), 6)}
</Text>
</div>
</Card>
)}
</div>
);
};
export default VideoModelPanel;