Initial import of weiyuan frontend
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user