feat: 参考原型图 ui优化提交 个人端-用户中心 相关的页面
This commit is contained in:
@@ -18,17 +18,19 @@ 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 { Button, Drawer, Spin } from 'antd';
|
||||
|
||||
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
|
||||
import { useMarketThemeStyle } from '../market/marketTheme';
|
||||
import ModelHeader from './components/ModelHeader';
|
||||
import ModelBasicInfo from './components/ModelBasicInfo';
|
||||
import ModelEndpoints from './components/ModelEndpoints';
|
||||
import ModelPricingTable from './components/ModelPricingTable';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
/**
|
||||
* 模型详情:原型为右侧 820px Drawer(窄屏铺满)。
|
||||
* 打开条件、关闭回调(遮罩 / Esc / 关闭按钮均走 onClose)与内容数据源保持原实现。
|
||||
*/
|
||||
const ModelDetailSideSheet = ({
|
||||
visible,
|
||||
onClose,
|
||||
@@ -47,134 +49,55 @@ const ModelDetailSideSheet = ({
|
||||
t,
|
||||
}) => {
|
||||
const isMobile = useIsMobile();
|
||||
const themeStyle = useMarketThemeStyle();
|
||||
|
||||
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)',
|
||||
}}
|
||||
<Drawer
|
||||
title={t('模型详情')}
|
||||
open={visible}
|
||||
onClose={onClose}
|
||||
width={isMobile ? '100%' : 820}
|
||||
rootClassName='mm-detail-drawer mm-theme'
|
||||
rootStyle={themeStyle}
|
||||
footer={
|
||||
<div className='mm-detail-footer'>
|
||||
<Button type='primary' onClick={onClose}>
|
||||
{t('关闭')}
|
||||
</Button>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
{/* 自定义头部 */}
|
||||
<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>
|
||||
{!modelData ? (
|
||||
<div className='mm-detail-loading'>
|
||||
<Spin size='large' />
|
||||
<span>{t('加载中...')}</span>
|
||||
</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>
|
||||
) : (
|
||||
<>
|
||||
<ModelHeader modelData={modelData} vendorsMap={vendorsMap} t={t} />
|
||||
<ModelBasicInfo modelData={modelData} vendorsMap={vendorsMap} t={t} />
|
||||
<ModelEndpoints
|
||||
modelData={modelData}
|
||||
endpointMap={endpointMap}
|
||||
t={t}
|
||||
/>
|
||||
{!hidePrice && (
|
||||
<ModelPricingTable
|
||||
modelData={modelData}
|
||||
groupRatio={groupRatio}
|
||||
groupModelDiscount={groupModelDiscount}
|
||||
currency={currency}
|
||||
tokenUnit={tokenUnit}
|
||||
displayPrice={displayPrice}
|
||||
showRatio={showRatio}
|
||||
usableGroup={usableGroup}
|
||||
autoGroups={autoGroups}
|
||||
t={t}
|
||||
/>
|
||||
)}
|
||||
</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>
|
||||
</>
|
||||
)}
|
||||
</Drawer>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
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 } from '@douyinfe/semi-ui';
|
||||
import { resetPricingFilters } from '../../../../helpers/utils';
|
||||
import FilterModalContent from './components/FilterModalContent';
|
||||
import FilterModalFooter from './components/FilterModalFooter';
|
||||
|
||||
const PricingFilterModal = ({ visible, onClose, sidebarProps, t }) => {
|
||||
const handleResetFilters = () =>
|
||||
resetPricingFilters({
|
||||
handleChange: sidebarProps.handleChange,
|
||||
setShowWithRecharge: sidebarProps.setShowWithRecharge,
|
||||
setCurrency: sidebarProps.setCurrency,
|
||||
setViewMode: sidebarProps.setViewMode,
|
||||
setFilterGroup: sidebarProps.setFilterGroup,
|
||||
setFilterQuotaType: sidebarProps.setFilterQuotaType,
|
||||
setFilterEndpointType: sidebarProps.setFilterEndpointType,
|
||||
setFilterVendor: sidebarProps.setFilterVendor,
|
||||
setFilterTag: sidebarProps.setFilterTag,
|
||||
setCurrentPage: sidebarProps.setCurrentPage,
|
||||
setTokenUnit: sidebarProps.setTokenUnit,
|
||||
});
|
||||
|
||||
const footer = (
|
||||
<FilterModalFooter onReset={handleResetFilters} onConfirm={onClose} t={t} />
|
||||
);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t('筛选')}
|
||||
visible={visible}
|
||||
onCancel={onClose}
|
||||
footer={footer}
|
||||
className='pricing-filter-modal'
|
||||
style={{ width: '100%', height: '100%', margin: 0 }}
|
||||
bodyStyle={{
|
||||
padding: 0,
|
||||
height: 'calc(100vh - 160px)',
|
||||
overflowY: 'auto',
|
||||
scrollbarWidth: 'none',
|
||||
msOverflowStyle: 'none',
|
||||
backgroundColor: 'var(--semi-color-bg-0)',
|
||||
}}
|
||||
>
|
||||
<FilterModalContent sidebarProps={sidebarProps} t={t} />
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default PricingFilterModal;
|
||||
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
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 PricingDisplaySettings from '../../filter/PricingDisplaySettings';
|
||||
import PricingGroups from '../../filter/PricingGroups';
|
||||
import PricingQuotaTypes from '../../filter/PricingQuotaTypes';
|
||||
import PricingEndpointTypes from '../../filter/PricingEndpointTypes';
|
||||
import PricingVendors from '../../filter/PricingVendors';
|
||||
import PricingTags from '../../filter/PricingTags';
|
||||
import { usePricingFilterCounts } from '../../../../../hooks/model-pricing/usePricingFilterCounts';
|
||||
|
||||
const FilterModalContent = ({ sidebarProps, t }) => {
|
||||
const {
|
||||
showWithRecharge,
|
||||
setShowWithRecharge,
|
||||
currency,
|
||||
setCurrency,
|
||||
handleChange,
|
||||
setActiveKey,
|
||||
showRatio,
|
||||
viewMode,
|
||||
setViewMode,
|
||||
filterGroup,
|
||||
setFilterGroup,
|
||||
filterQuotaType,
|
||||
setFilterQuotaType,
|
||||
filterEndpointType,
|
||||
setFilterEndpointType,
|
||||
filterVendor,
|
||||
setFilterVendor,
|
||||
filterTag,
|
||||
setFilterTag,
|
||||
tokenUnit,
|
||||
setTokenUnit,
|
||||
loading,
|
||||
...categoryProps
|
||||
} = sidebarProps;
|
||||
|
||||
const {
|
||||
quotaTypeModels,
|
||||
endpointTypeModels,
|
||||
vendorModels,
|
||||
tagModels,
|
||||
groupCountModels,
|
||||
} = usePricingFilterCounts({
|
||||
models: categoryProps.models,
|
||||
filterGroup,
|
||||
filterQuotaType,
|
||||
filterEndpointType,
|
||||
filterVendor,
|
||||
filterTag,
|
||||
searchValue: sidebarProps.searchValue,
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<PricingDisplaySettings
|
||||
showWithRecharge={showWithRecharge}
|
||||
setShowWithRecharge={setShowWithRecharge}
|
||||
currency={currency}
|
||||
setCurrency={setCurrency}
|
||||
showRatio={showRatio}
|
||||
viewMode={viewMode}
|
||||
setViewMode={setViewMode}
|
||||
tokenUnit={tokenUnit}
|
||||
setTokenUnit={setTokenUnit}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<PricingVendors
|
||||
filterVendor={filterVendor}
|
||||
setFilterVendor={setFilterVendor}
|
||||
models={vendorModels}
|
||||
allModels={categoryProps.models}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<PricingTags
|
||||
filterTag={filterTag}
|
||||
setFilterTag={setFilterTag}
|
||||
models={tagModels}
|
||||
allModels={categoryProps.models}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<PricingGroups
|
||||
filterGroup={filterGroup}
|
||||
setFilterGroup={setFilterGroup}
|
||||
usableGroup={categoryProps.usableGroup}
|
||||
groupRatio={categoryProps.groupRatio}
|
||||
models={groupCountModels}
|
||||
loading={loading}
|
||||
showRatio={showRatio}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<PricingQuotaTypes
|
||||
filterQuotaType={filterQuotaType}
|
||||
setFilterQuotaType={setFilterQuotaType}
|
||||
models={quotaTypeModels}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<PricingEndpointTypes
|
||||
filterEndpointType={filterEndpointType}
|
||||
setFilterEndpointType={setFilterEndpointType}
|
||||
models={endpointTypeModels}
|
||||
allModels={categoryProps.models}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default FilterModalContent;
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
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 { Button } from '@douyinfe/semi-ui';
|
||||
|
||||
const FilterModalFooter = ({ onReset, onConfirm, t }) => {
|
||||
return (
|
||||
<div className='flex justify-end'>
|
||||
<Button theme='outline' type='tertiary' onClick={onReset}>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
<Button theme='solid' type='primary' onClick={onConfirm}>
|
||||
{t('确定')}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FilterModalFooter;
|
||||
@@ -18,11 +18,13 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { FileText, Sparkles } from 'lucide-react';
|
||||
import { stringToColor } from '../../../../../helpers';
|
||||
import { Tag } from 'antd';
|
||||
|
||||
const ModelBasicInfo = ({ modelData, vendorsMap = {}, t }) => {
|
||||
// 获取模型描述
|
||||
/**
|
||||
* 详情「基本信息」:描述取值顺序(模型描述 → 供应商信息 → 暂无)与标签拆分规则沿用原实现。
|
||||
* 原型未定义标签样式,使用 Ant Design 默认 Tag。
|
||||
*/
|
||||
const ModelBasicInfo = ({ modelData, t }) => {
|
||||
const getModelDescription = () => {
|
||||
if (!modelData) return t('暂无模型描述');
|
||||
if (modelData.description) return modelData.description;
|
||||
@@ -31,59 +33,25 @@ const ModelBasicInfo = ({ modelData, vendorsMap = {}, t }) => {
|
||||
return t('暂无模型描述');
|
||||
};
|
||||
|
||||
// 获取模型标签
|
||||
const getModelTags = () => {
|
||||
const tags = [];
|
||||
if (modelData?.tags) {
|
||||
const customTags = modelData.tags.split(',').filter((tag) => tag.trim());
|
||||
customTags.forEach((tag) => {
|
||||
const tagText = tag.trim();
|
||||
tags.push({ text: tagText, color: stringToColor(tagText) });
|
||||
});
|
||||
}
|
||||
return tags;
|
||||
};
|
||||
|
||||
const tags = getModelTags();
|
||||
const tags = modelData?.tags
|
||||
? modelData.tags
|
||||
.split(',')
|
||||
.map((tag) => tag.trim())
|
||||
.filter(Boolean)
|
||||
: [];
|
||||
|
||||
return (
|
||||
<div className='space-y-3'>
|
||||
{/* 标题行 —— 单行紧凑小节头(原大色块 chip+副标题在弹窗内层级过重) */}
|
||||
<h3 className='flex items-center gap-1.5 text-[13px] font-semibold text-gray-900 dark:text-white'>
|
||||
<FileText
|
||||
size={14}
|
||||
className='text-brand-deep dark:text-brand-from flex-shrink-0'
|
||||
/>
|
||||
{t('基本信息')}
|
||||
</h3>
|
||||
|
||||
{/* 描述区域 */}
|
||||
<div className='relative pl-3'>
|
||||
<div className='absolute left-0 top-0 bottom-0 w-0.5 rounded-full bg-brand-from' />
|
||||
<p className='text-sm text-gray-600 dark:text-gray-300 leading-relaxed'>
|
||||
{getModelDescription()}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 标签区域 */}
|
||||
<section className='mm-detail-section'>
|
||||
<h3>{t('基本信息')}</h3>
|
||||
<p className='mm-detail-description'>{getModelDescription()}</p>
|
||||
{tags.length > 0 && (
|
||||
<div className='flex flex-wrap gap-1.5'>
|
||||
<div className='mm-detail-tags'>
|
||||
{tags.map((tag, index) => (
|
||||
<span
|
||||
key={index}
|
||||
className='inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium'
|
||||
style={{
|
||||
backgroundColor: `${tag.color}15`,
|
||||
color: tag.color,
|
||||
}}
|
||||
>
|
||||
<Sparkles size={10} />
|
||||
{tag.text}
|
||||
</span>
|
||||
<Tag key={`${tag}-${index}`}>{tag}</Tag>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -18,8 +18,11 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Plug, Zap, ArrowRight, Globe } from 'lucide-react';
|
||||
import { Empty, Tag } from 'antd';
|
||||
|
||||
/**
|
||||
* 详情「API 端点」:端点路径中的 {model} 替换与默认 POST 方法沿用原实现。
|
||||
*/
|
||||
const ModelEndpoints = ({ modelData, endpointMap = {}, t }) => {
|
||||
const types = modelData?.supported_endpoint_types || [];
|
||||
|
||||
@@ -33,96 +36,33 @@ const ModelEndpoints = ({ modelData, endpointMap = {}, t }) => {
|
||||
return { path, method: info.method || 'POST' };
|
||||
};
|
||||
|
||||
const getMethodColor = (method) => {
|
||||
const colors = {
|
||||
GET: {
|
||||
bg: 'bg-emerald-500/10',
|
||||
text: 'text-emerald-600 dark:text-emerald-400',
|
||||
border: 'border-emerald-500/20',
|
||||
},
|
||||
POST: {
|
||||
bg: 'bg-blue-500/10',
|
||||
text: 'text-blue-600 dark:text-blue-400',
|
||||
border: 'border-blue-500/20',
|
||||
},
|
||||
PUT: {
|
||||
bg: 'bg-amber-500/10',
|
||||
text: 'text-amber-600 dark:text-amber-400',
|
||||
border: 'border-amber-500/20',
|
||||
},
|
||||
DELETE: {
|
||||
bg: 'bg-red-500/10',
|
||||
text: 'text-red-600 dark:text-red-400',
|
||||
border: 'border-red-500/20',
|
||||
},
|
||||
};
|
||||
return colors[method] || colors.POST;
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='space-y-3'>
|
||||
{/* 标题区域 —— 单行紧凑小节头 */}
|
||||
<div className='flex items-center justify-between'>
|
||||
<h3 className='flex items-center gap-1.5 text-[13px] font-semibold text-gray-900 dark:text-white'>
|
||||
<Plug
|
||||
size={14}
|
||||
className='text-brand-deep dark:text-brand-from flex-shrink-0'
|
||||
/>
|
||||
{t('API端点')}
|
||||
</h3>
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400 font-medium'>
|
||||
<Globe size={12} className='inline mr-1' />
|
||||
<section className='mm-detail-section'>
|
||||
<div className='mm-detail-section-head'>
|
||||
<h3>{t('API 端点')}</h3>
|
||||
<span>
|
||||
{types.length} {t('个端点')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* 端点列表 */}
|
||||
<div className='space-y-2'>
|
||||
{types.map((type) => {
|
||||
const { path, method } = getEndpointInfo(type);
|
||||
const methodStyle = getMethodColor(method);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={type}
|
||||
className='flex items-center justify-between gap-3 py-2'
|
||||
>
|
||||
<div className='flex-1 min-w-0'>
|
||||
<div className='flex items-center gap-2'>
|
||||
<Zap size={12} className='text-brand flex-shrink-0' />
|
||||
<span className='text-sm font-medium text-gray-900 dark:text-white'>
|
||||
{type}
|
||||
</span>
|
||||
</div>
|
||||
{path && (
|
||||
<div className='flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 mt-0.5 ml-5'>
|
||||
<ArrowRight size={10} className='flex-shrink-0' />
|
||||
<code className='font-mono text-gray-600 dark:text-gray-300'>
|
||||
{path}
|
||||
</code>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{path && (
|
||||
<span
|
||||
className={`flex-shrink-0 px-2 py-0.5 rounded text-xs font-semibold ${methodStyle.bg} ${methodStyle.text}`}
|
||||
>
|
||||
{method}
|
||||
</span>
|
||||
)}
|
||||
{types.map((type) => {
|
||||
const { path, method } = getEndpointInfo(type);
|
||||
return (
|
||||
<div key={type} className='mm-detail-endpoint'>
|
||||
<div>
|
||||
<strong>{type}</strong>
|
||||
{path && <code>{path}</code>}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{path && <Tag bordered={false}>{method}</Tag>}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{types.length === 0 && (
|
||||
<div className='text-center py-6 text-gray-400 dark:text-gray-500'>
|
||||
<Plug size={24} className='mx-auto mb-2 opacity-50' />
|
||||
<p className='text-sm'>{t('暂无端点信息')}</p>
|
||||
</div>
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={t('暂无端点信息')}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -18,79 +18,34 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { Typography, Toast, Avatar } from '@douyinfe/semi-ui';
|
||||
import { getLobeHubIcon } from '../../../../../helpers';
|
||||
import { Typography } from 'antd';
|
||||
import { Copy } from 'lucide-react';
|
||||
import { showSuccess } from '../../../../../helpers';
|
||||
import MarketLogo from '../../market/MarketLogo';
|
||||
|
||||
const { Paragraph } = Typography;
|
||||
|
||||
const CARD_STYLES = {
|
||||
container:
|
||||
'w-12 h-12 rounded-2xl flex items-center justify-center relative shadow-md',
|
||||
icon: 'w-8 h-8 flex items-center justify-center',
|
||||
};
|
||||
|
||||
const ModelHeader = ({ modelData, vendorsMap = {}, t }) => {
|
||||
// 获取模型图标(优先模型图标,其次供应商图标)
|
||||
const getModelIcon = () => {
|
||||
// 1) 优先使用模型自定义图标
|
||||
if (modelData?.icon) {
|
||||
return (
|
||||
<div className={CARD_STYLES.container}>
|
||||
<div className={CARD_STYLES.icon}>
|
||||
{getLobeHubIcon(modelData.icon, 32)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
// 2) 退化为供应商图标
|
||||
if (modelData?.vendor_icon) {
|
||||
return (
|
||||
<div className={CARD_STYLES.container}>
|
||||
<div className={CARD_STYLES.icon}>
|
||||
{getLobeHubIcon(modelData.vendor_icon, 32)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 如果没有供应商图标,使用模型名称的前两个字符
|
||||
const avatarText = modelData?.model_name?.slice(0, 2).toUpperCase() || 'AI';
|
||||
return (
|
||||
<div className={CARD_STYLES.container}>
|
||||
<Avatar
|
||||
size='large'
|
||||
style={{
|
||||
width: 48,
|
||||
height: 48,
|
||||
borderRadius: 16,
|
||||
fontSize: 16,
|
||||
fontWeight: 'bold',
|
||||
}}
|
||||
>
|
||||
{avatarText}
|
||||
</Avatar>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='flex items-center'>
|
||||
{getModelIcon()}
|
||||
<div className='ml-3 font-normal'>
|
||||
<Paragraph
|
||||
className='!mb-0 !text-lg !font-medium'
|
||||
copyable={{
|
||||
content: modelData?.model_name || '',
|
||||
onCopy: () => Toast.success({ content: t('已复制模型名称') }),
|
||||
}}
|
||||
>
|
||||
<span className='truncate max-w-60 font-bold'>
|
||||
{modelData?.model_name || t('未知模型')}
|
||||
</span>
|
||||
</Paragraph>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
/**
|
||||
* 详情头部:模型图标(优先模型图标,其次供应商图标,最后名称缩写)+ 名称 + 复制。
|
||||
* 复制沿用 Typography copyable 与原「已复制模型名称」成功提示。
|
||||
*/
|
||||
const ModelHeader = ({ modelData, t }) => (
|
||||
<div className='mm-detail-model'>
|
||||
<MarketLogo
|
||||
icon={modelData?.icon || modelData?.vendor_icon}
|
||||
fallbackText={modelData?.model_name}
|
||||
size={26}
|
||||
/>
|
||||
<Typography.Title
|
||||
level={2}
|
||||
copyable={{
|
||||
text: modelData?.model_name || '',
|
||||
icon: <Copy size={16} strokeWidth={1.65} />,
|
||||
tooltips: [t('复制模型名称'), t('已复制模型名称')],
|
||||
onCopy: () => showSuccess(t('已复制模型名称')),
|
||||
}}
|
||||
>
|
||||
{modelData?.model_name || t('未知模型')}
|
||||
</Typography.Title>
|
||||
</div>
|
||||
);
|
||||
|
||||
export default ModelHeader;
|
||||
|
||||
@@ -18,19 +18,18 @@ For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
Coins,
|
||||
ChevronRight,
|
||||
Layers,
|
||||
Calculator,
|
||||
BadgePercent,
|
||||
} from 'lucide-react';
|
||||
import { Empty, Table, Tag, Tooltip } from 'antd';
|
||||
import { ChevronRight } from 'lucide-react';
|
||||
import {
|
||||
calculateModelPrice,
|
||||
formatOfficialPriceDisplay,
|
||||
getDiscountBadgeText,
|
||||
} from '../../../../../helpers';
|
||||
|
||||
/**
|
||||
* 详情「分组价格」:原型为 Ant Design Table(small)。
|
||||
* 可用分组、auto 链路、官方价参考行、各计费类型的列与价格计算全部沿用原实现,仅改为 Table 呈现。
|
||||
*/
|
||||
const ModelPricingTable = ({
|
||||
modelData,
|
||||
groupRatio,
|
||||
@@ -38,7 +37,6 @@ const ModelPricingTable = ({
|
||||
currency,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
showRatio,
|
||||
usableGroup,
|
||||
autoGroups = [],
|
||||
t,
|
||||
@@ -96,262 +94,173 @@ const ModelPricingTable = ({
|
||||
const extraPriceColumns = Array.isArray(samplePriceData?.extraPrices)
|
||||
? samplePriceData.extraPrices
|
||||
: [];
|
||||
// 按秒分档:列 = 各档位,由配置顺序决定
|
||||
const videoTierColumns = isPerSecond
|
||||
// 按秒 / 按分辨率分档:列 = 各档位,由配置顺序决定
|
||||
const tierColumns = isPerSecond
|
||||
? (modelData?.video_second_pricing?.tiers || []).map((tier) => ({
|
||||
key: tier.key,
|
||||
label: tier.label || tier.key,
|
||||
}))
|
||||
: [];
|
||||
const imageTierColumns = isPerImageResolution
|
||||
? (modelData?.image_resolution_pricing?.tiers || []).map((tier) => ({
|
||||
key: tier.key,
|
||||
label: tier.label || tier.key,
|
||||
}))
|
||||
: [];
|
||||
const tierColumns = isPerSecond ? videoTierColumns : imageTierColumns;
|
||||
: isPerImageResolution
|
||||
? (modelData?.image_resolution_pricing?.tiers || []).map((tier) => ({
|
||||
key: tier.key,
|
||||
label: tier.label || tier.key,
|
||||
}))
|
||||
: [];
|
||||
const isTierPricing = isPerSecond || isPerImageResolution;
|
||||
const priceGridStyle = isTierPricing
|
||||
? {
|
||||
gridTemplateColumns: `minmax(76px, 1fr) repeat(${Math.max(tierColumns.length, 1)}, minmax(88px, max-content))`,
|
||||
minWidth:
|
||||
tierColumns.length > 0
|
||||
? `${160 + tierColumns.length * 100}px`
|
||||
: undefined,
|
||||
}
|
||||
: isPerToken
|
||||
? {
|
||||
gridTemplateColumns: `minmax(76px, 1fr) repeat(${2 + extraPriceColumns.length}, minmax(88px, max-content))`,
|
||||
minWidth:
|
||||
extraPriceColumns.length > 0
|
||||
? `${260 + extraPriceColumns.length * 108}px`
|
||||
: undefined,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
const price = (value, extra = false) => (
|
||||
<span className={`mm-detail-price${extra ? ' mm-detail-price-extra' : ''}`}>
|
||||
{value || '-'}
|
||||
</span>
|
||||
);
|
||||
const official = (value) => <del className='mm-official'>{value || '-'}</del>;
|
||||
|
||||
const groupColumn = {
|
||||
title: t('分组'),
|
||||
dataIndex: 'group',
|
||||
key: 'group',
|
||||
width: 180,
|
||||
render: (_, row) =>
|
||||
row.official ? (
|
||||
<span
|
||||
className='mm-detail-group mm-official'
|
||||
title={t('管理员维护的模型原厂牌价,未含分组倍率,仅供对照')}
|
||||
>
|
||||
{t('官方价')}
|
||||
</span>
|
||||
) : (
|
||||
<span className='mm-detail-group'>
|
||||
{row.group}
|
||||
{row.discountText && (
|
||||
<Tooltip
|
||||
title={t(
|
||||
'相比官方牌价的折扣,按当前计价分组实付价计算(已含您的等级折扣),仅供参考',
|
||||
)}
|
||||
>
|
||||
<Tag bordered={false}>{row.discountText}</Tag>
|
||||
</Tooltip>
|
||||
)}
|
||||
</span>
|
||||
),
|
||||
};
|
||||
|
||||
let priceColumns;
|
||||
if (isTierPricing) {
|
||||
const unit = isPerSecond ? t('秒') : t('张');
|
||||
priceColumns = tierColumns.map((col) => ({
|
||||
title: `${col.label} / ${unit}`,
|
||||
key: col.key,
|
||||
align: 'right',
|
||||
width: 135,
|
||||
render: (_, row) => {
|
||||
const tiers = isPerSecond
|
||||
? row.priceData.videoTiers
|
||||
: row.priceData.imageTiers;
|
||||
return price(tiers?.find((tier) => tier.key === col.key)?.price);
|
||||
},
|
||||
}));
|
||||
} else if (isPerToken) {
|
||||
priceColumns = [
|
||||
{
|
||||
title: `${t('输入价格')} / ${tokenLabel}`,
|
||||
key: 'input',
|
||||
align: 'right',
|
||||
width: 135,
|
||||
render: (_, row) =>
|
||||
row.official
|
||||
? official(officialDisplay.input)
|
||||
: price(row.priceData.inputPrice),
|
||||
},
|
||||
{
|
||||
title: `${t('输出价格')} / ${tokenLabel}`,
|
||||
key: 'output',
|
||||
align: 'right',
|
||||
width: 135,
|
||||
render: (_, row) =>
|
||||
row.official
|
||||
? official(officialDisplay.output)
|
||||
: price(row.priceData.completionPrice || row.priceData.outputPrice),
|
||||
},
|
||||
...extraPriceColumns.map((column) => ({
|
||||
title: `${t(column.labelKey)} / ${tokenLabel}`,
|
||||
key: column.key,
|
||||
align: 'right',
|
||||
width: 135,
|
||||
render: (_, row) =>
|
||||
row.official
|
||||
? official(null)
|
||||
: price(
|
||||
row.priceData.extraPrices?.find(
|
||||
(extra) => extra.key === column.key,
|
||||
)?.price,
|
||||
true,
|
||||
),
|
||||
})),
|
||||
];
|
||||
} else {
|
||||
priceColumns = [
|
||||
{
|
||||
title: `${t('单价')} / ${t('次')}`,
|
||||
key: 'price',
|
||||
align: 'right',
|
||||
width: 135,
|
||||
render: (_, row) =>
|
||||
row.official
|
||||
? official(officialDisplay.perCall)
|
||||
: price(row.priceData.price),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
const dataSource = [
|
||||
...(officialDisplay && !isTierPricing
|
||||
? [{ key: '__official__', official: true }]
|
||||
: []),
|
||||
...availableGroups.map((group, idx) => ({
|
||||
key: group,
|
||||
group,
|
||||
priceData: groupPriceDataList[idx],
|
||||
discountText: getDiscountBadgeText(groupPriceDataList[idx]),
|
||||
})),
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='space-y-3'>
|
||||
{/* 标题区域 —— 单行紧凑小节头 */}
|
||||
<div className='flex items-center justify-between'>
|
||||
<h3 className='flex items-center gap-1.5 text-[13px] font-semibold text-gray-900 dark:text-white'>
|
||||
<Coins
|
||||
size={14}
|
||||
className='text-brand-deep dark:text-brand-from flex-shrink-0'
|
||||
/>
|
||||
{t('分组价格')}
|
||||
</h3>
|
||||
<span className='text-xs text-gray-500 dark:text-gray-400 font-medium'>
|
||||
<Calculator size={12} className='inline mr-1' />
|
||||
{billingLabel}
|
||||
</span>
|
||||
<section className='mm-detail-section'>
|
||||
<div className='mm-detail-section-head'>
|
||||
<h3>{t('分组价格')}</h3>
|
||||
<span>{billingLabel}</span>
|
||||
</div>
|
||||
|
||||
{/* Auto分组链路 */}
|
||||
{autoChain.length > 0 && (
|
||||
<div className='flex items-center flex-wrap gap-1.5 text-xs text-gray-500 dark:text-gray-400'>
|
||||
<Layers size={12} className='text-brand' />
|
||||
<div className='mm-detail-auto'>
|
||||
<span>{t('auto分组调用链路')}</span>
|
||||
{autoChain.map((g, idx) => (
|
||||
<React.Fragment key={g}>
|
||||
<span className='px-1.5 py-0.5 rounded text-brand-deep dark:text-brand-from font-medium bg-brand/10'>
|
||||
{g}
|
||||
</span>
|
||||
{idx < autoChain.length - 1 && (
|
||||
<ChevronRight size={10} className='text-gray-400' />
|
||||
)}
|
||||
<Tag bordered={false}>{g}</Tag>
|
||||
{idx < autoChain.length - 1 && <ChevronRight size={12} />}
|
||||
</React.Fragment>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 价格表格 */}
|
||||
<div className='overflow-x-auto'>
|
||||
{/* 表头 */}
|
||||
<div
|
||||
className={`grid ${isPerToken || isTierPricing ? '' : 'grid-cols-2'} text-[11px] font-medium text-gray-400 dark:text-gray-400 border-b border-gray-100 dark:border-neutral-700 pb-2 mb-1`}
|
||||
style={priceGridStyle}
|
||||
>
|
||||
<div>{t('分组')}</div>
|
||||
{isPerSecond ? (
|
||||
videoTierColumns.map((col) => (
|
||||
<div key={col.key} className='text-right'>
|
||||
{col.label} / {t('秒')}
|
||||
</div>
|
||||
))
|
||||
) : isPerImageResolution ? (
|
||||
imageTierColumns.map((col) => (
|
||||
<div key={col.key} className='text-right'>
|
||||
{col.label} / {t('张')}
|
||||
</div>
|
||||
))
|
||||
) : isPerToken ? (
|
||||
<>
|
||||
<div className='text-right'>
|
||||
{t('输入价格')} / {tokenLabel}
|
||||
</div>
|
||||
<div className='text-right'>
|
||||
{t('输出价格')} / {tokenLabel}
|
||||
</div>
|
||||
{extraPriceColumns.map((item) => (
|
||||
<div key={item.key} className='text-right'>
|
||||
{t(item.labelKey)} / {tokenLabel}
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
) : (
|
||||
<div className='text-right'>
|
||||
{t('单价')} / {t('次')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 官方价参考行:管理员维护的原厂牌价(不含分组倍率),供各分组折扣对照 */}
|
||||
{officialDisplay && !isTierPricing && (
|
||||
<div
|
||||
className={`grid ${isPerToken ? '' : 'grid-cols-2'} items-center py-1.5 rounded-lg bg-gray-50/80 dark:bg-neutral-800/60`}
|
||||
style={priceGridStyle}
|
||||
>
|
||||
<div className='flex items-center gap-1.5 pl-1'>
|
||||
<BadgePercent size={12} className='text-gray-400' />
|
||||
<span
|
||||
className='text-sm text-gray-500 dark:text-gray-400'
|
||||
title={t('管理员维护的模型原厂牌价,未含分组倍率,仅供对照')}
|
||||
>
|
||||
{t('官方价')}
|
||||
</span>
|
||||
</div>
|
||||
{isPerToken ? (
|
||||
<>
|
||||
<div className='text-right'>
|
||||
<span className='text-sm text-gray-500 dark:text-gray-400 line-through'>
|
||||
{officialDisplay.input || '-'}
|
||||
</span>
|
||||
</div>
|
||||
<div className='text-right'>
|
||||
<span className='text-sm text-gray-500 dark:text-gray-400 line-through'>
|
||||
{officialDisplay.output || '-'}
|
||||
</span>
|
||||
</div>
|
||||
{extraPriceColumns.map((column) => (
|
||||
<div key={column.key} className='text-right'>
|
||||
<span className='text-sm text-gray-400'>-</span>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
) : (
|
||||
<div className='text-right'>
|
||||
<span className='text-sm text-gray-500 dark:text-gray-400 line-through'>
|
||||
{officialDisplay.perCall || '-'}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 数据行 */}
|
||||
<div className='space-y-0.5'>
|
||||
{availableGroups.map((group, idx) => {
|
||||
const priceData = groupPriceDataList[idx];
|
||||
const discountText = getDiscountBadgeText(priceData);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={group}
|
||||
className={`grid ${isPerToken || isTierPricing ? '' : 'grid-cols-2'} items-center py-1.5`}
|
||||
style={priceGridStyle}
|
||||
>
|
||||
<div className='flex items-center gap-1.5'>
|
||||
<span
|
||||
className={`w-1.5 h-1.5 rounded-full ${idx % 3 === 0 ? 'bg-emerald-500' : idx % 3 === 1 ? 'bg-blue-500' : 'bg-brand'}`}
|
||||
/>
|
||||
<span className='text-sm text-gray-700 dark:text-gray-200'>
|
||||
{group}
|
||||
</span>
|
||||
{discountText && (
|
||||
<span
|
||||
className='px-1.5 py-[1px] rounded-full text-[10px] font-semibold leading-4
|
||||
text-brand-deep dark:text-brand-from bg-brand/10 dark:bg-brand-deep/30
|
||||
border border-brand/25 dark:border-brand-deep/50 select-none'
|
||||
title={t(
|
||||
'相比官方牌价的折扣,按当前计价分组实付价计算(已含您的等级折扣),仅供参考',
|
||||
)}
|
||||
>
|
||||
{discountText}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{isPerSecond ? (
|
||||
videoTierColumns.map((col) => {
|
||||
const tier = priceData.videoTiers?.find(
|
||||
(vt) => vt.key === col.key,
|
||||
);
|
||||
return (
|
||||
<div key={col.key} className='text-right'>
|
||||
<span className='text-sm font-semibold text-emerald-600 dark:text-emerald-400'>
|
||||
{tier?.price || '-'}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})
|
||||
) : isPerImageResolution ? (
|
||||
imageTierColumns.map((col) => {
|
||||
const tier = priceData.imageTiers?.find(
|
||||
(imageTier) => imageTier.key === col.key,
|
||||
);
|
||||
return (
|
||||
<div key={col.key} className='text-right'>
|
||||
<span className='text-sm font-semibold text-sky-600 dark:text-sky-400'>
|
||||
{tier?.price || '-'}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})
|
||||
) : isPerToken ? (
|
||||
<>
|
||||
<div className='text-right'>
|
||||
<span className='text-sm font-semibold text-orange-600 dark:text-orange-400'>
|
||||
{priceData.inputPrice}
|
||||
</span>
|
||||
</div>
|
||||
<div className='text-right'>
|
||||
<span className='text-sm font-semibold text-rose-600 dark:text-rose-400'>
|
||||
{priceData.completionPrice || priceData.outputPrice}
|
||||
</span>
|
||||
</div>
|
||||
{extraPriceColumns.map((column) => {
|
||||
const item = priceData.extraPrices?.find(
|
||||
(extra) => extra.key === column.key,
|
||||
);
|
||||
return (
|
||||
<div key={column.key} className='text-right'>
|
||||
<span className='text-sm font-semibold text-sky-600 dark:text-sky-400'>
|
||||
{item?.price || '-'}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
) : (
|
||||
<div className='text-right'>
|
||||
<span className='text-sm font-semibold text-brand-deep dark:text-brand-from'>
|
||||
{priceData.price}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{availableGroups.length === 0 && (
|
||||
<div className='text-center py-4 text-gray-400 dark:text-gray-400 text-xs'>
|
||||
<Coins size={18} className='mx-auto mb-1 opacity-50' />
|
||||
{t('暂无价格信息')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<Table
|
||||
className='mm-detail-table'
|
||||
size='small'
|
||||
rowKey='key'
|
||||
pagination={false}
|
||||
scroll={{ x: 'max-content' }}
|
||||
columns={[groupColumn, ...priceColumns]}
|
||||
dataSource={dataSource}
|
||||
locale={{
|
||||
emptyText: (
|
||||
<Empty
|
||||
image={Empty.PRESENTED_IMAGE_SIMPLE}
|
||||
description={t('暂无价格信息')}
|
||||
/>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user