Initial import of weiyuan frontend
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
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 { Modal, Typography, Button, Spin } from '@douyinfe/semi-ui';
|
||||
import { X, Bot } from 'lucide-react';
|
||||
|
||||
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
|
||||
import ModelHeader from './components/ModelHeader';
|
||||
import ModelBasicInfo from './components/ModelBasicInfo';
|
||||
import ModelEndpoints from './components/ModelEndpoints';
|
||||
import ModelPricingTable from './components/ModelPricingTable';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const ModelDetailSideSheet = ({
|
||||
visible,
|
||||
onClose,
|
||||
modelData,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
currency,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
showRatio,
|
||||
hidePrice,
|
||||
usableGroup,
|
||||
vendorsMap,
|
||||
endpointMap,
|
||||
autoGroups,
|
||||
t,
|
||||
}) => {
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={null}
|
||||
header={null}
|
||||
footer={null}
|
||||
bodyStyle={{
|
||||
padding: '0',
|
||||
borderRadius: '20px',
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
className='model-detail-modal'
|
||||
visible={visible}
|
||||
width={isMobile ? '95%' : 560}
|
||||
centered
|
||||
closeIcon={null}
|
||||
onCancel={onClose}
|
||||
maskClosable={true}
|
||||
maskStyle={{
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.4)',
|
||||
backdropFilter: 'blur(8px)',
|
||||
}}
|
||||
>
|
||||
{/* 自定义头部 */}
|
||||
<div className='px-4 pt-4 pb-3'>
|
||||
<div className='flex items-center justify-between'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<div className='p-1.5 bg-gradient-to-br from-brand-from to-brand-to rounded-lg'>
|
||||
<Bot size={16} className='text-white' />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className='text-sm font-semibold text-gray-800 dark:text-gray-100'>
|
||||
{t('模型详情')}
|
||||
</h2>
|
||||
<p className='text-[11px] text-gray-500 dark:text-gray-400'>
|
||||
{t('查看模型定价与配置信息')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 关闭按钮 */}
|
||||
<button
|
||||
onClick={onClose}
|
||||
className='p-1.5 rounded-lg bg-gray-100 hover:bg-gray-200 dark:bg-neutral-800 dark:hover:bg-neutral-700 transition-colors'
|
||||
>
|
||||
<X size={16} className='text-gray-500 dark:text-gray-400' />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* 模型标题 */}
|
||||
{modelData && (
|
||||
<div className='mt-2'>
|
||||
<ModelHeader modelData={modelData} vendorsMap={vendorsMap} t={t} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 内容区域 */}
|
||||
<div
|
||||
className='overflow-y-auto'
|
||||
style={{
|
||||
maxHeight: isMobile ? 'calc(85vh - 180px)' : 'calc(75vh - 160px)',
|
||||
}}
|
||||
>
|
||||
<div className='px-4 pb-3'>
|
||||
{!modelData ? (
|
||||
<div className='flex flex-col justify-center items-center py-12'>
|
||||
<Spin size='large' />
|
||||
<Text type='secondary' className='mt-3'>
|
||||
{t('加载中...')}
|
||||
</Text>
|
||||
</div>
|
||||
) : (
|
||||
/* 分区平铺 + 发丝分隔线:原先每区一层白卡边框,与弹窗自身、
|
||||
* 区内表格边框叠出三层线框(用户反馈嵌套过多),改为零嵌套 */
|
||||
<div className='divide-y divide-gray-100 dark:divide-neutral-800'>
|
||||
{/* 基本信息 */}
|
||||
<div className='py-3 first:pt-1'>
|
||||
<ModelBasicInfo
|
||||
modelData={modelData}
|
||||
vendorsMap={vendorsMap}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 端点信息 */}
|
||||
<div className='py-3'>
|
||||
<ModelEndpoints
|
||||
modelData={modelData}
|
||||
endpointMap={endpointMap}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 定价表格 */}
|
||||
{!hidePrice && (
|
||||
<div className='py-3'>
|
||||
<ModelPricingTable
|
||||
modelData={modelData}
|
||||
groupRatio={groupRatio}
|
||||
groupModelDiscount={groupModelDiscount}
|
||||
currency={currency}
|
||||
tokenUnit={tokenUnit}
|
||||
displayPrice={displayPrice}
|
||||
showRatio={showRatio}
|
||||
usableGroup={usableGroup}
|
||||
autoGroups={autoGroups}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 底部按钮 */}
|
||||
<div className='px-4 pb-4 pt-2'>
|
||||
<Button
|
||||
block
|
||||
theme='solid'
|
||||
onClick={onClose}
|
||||
className='!bg-gradient-to-r !from-brand-from !to-brand-to hover:!from-brand-from hover:!to-brand-to !rounded-xl !h-10 !font-medium !shadow-md !shadow-brand/20 transition-all'
|
||||
>
|
||||
{t('关闭')}
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelDetailSideSheet;
|
||||
Reference in New Issue
Block a user