Initial import of weiyuan frontend
This commit is contained in:
@@ -0,0 +1,267 @@
|
||||
/*
|
||||
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 { Avatar } from '@douyinfe/semi-ui';
|
||||
import { Copy, Lock } from 'lucide-react';
|
||||
import {
|
||||
getLobeHubIcon,
|
||||
formatPriceInfo,
|
||||
getDiscountBadgeText,
|
||||
} from '../../../../helpers';
|
||||
|
||||
// Simplified vendor color schemes — fewer layers, better performance
|
||||
// tint: 用于卡片装饰纹理(点阵/柔光)的供应商主题色(text-* 供 currentColor 取色)
|
||||
// accentBg: 顶部识别色条。必须写成字面量类名——此前用
|
||||
// accent.replaceAll('border-','bg-') 运行时拼接,Tailwind JIT 扫不到
|
||||
// 拼接产物(bg-emerald-300 等未在源码中出现),色条实际从未渲染
|
||||
const vendorColors = {
|
||||
OpenAI: {
|
||||
accentBg: 'bg-emerald-300 dark:bg-emerald-700',
|
||||
bg: 'bg-emerald-50 dark:bg-emerald-900/20',
|
||||
border: 'border-emerald-200 dark:border-emerald-800/50',
|
||||
hoverBorder: 'hover:border-emerald-400 dark:hover:border-emerald-600',
|
||||
tint: 'text-emerald-600 dark:text-emerald-400',
|
||||
},
|
||||
Anthropic: {
|
||||
accentBg: 'bg-amber-300 dark:bg-amber-700',
|
||||
bg: 'bg-amber-50 dark:bg-amber-900/20',
|
||||
border: 'border-amber-200 dark:border-amber-800/50',
|
||||
hoverBorder: 'hover:border-amber-400 dark:hover:border-amber-600',
|
||||
tint: 'text-amber-600 dark:text-amber-400',
|
||||
},
|
||||
Google: {
|
||||
accentBg: 'bg-blue-300 dark:bg-blue-700',
|
||||
bg: 'bg-blue-50 dark:bg-blue-900/20',
|
||||
border: 'border-blue-200 dark:border-blue-800/50',
|
||||
hoverBorder: 'hover:border-blue-400 dark:hover:border-blue-600',
|
||||
tint: 'text-blue-600 dark:text-blue-400',
|
||||
},
|
||||
Meta: {
|
||||
accentBg: 'bg-blue-300 dark:bg-blue-700',
|
||||
bg: 'bg-blue-50 dark:bg-blue-900/20',
|
||||
border: 'border-blue-200 dark:border-blue-800/50',
|
||||
hoverBorder: 'hover:border-blue-400 dark:hover:border-blue-600',
|
||||
tint: 'text-blue-600 dark:text-blue-400',
|
||||
},
|
||||
Mistral: {
|
||||
accentBg: 'bg-orange-300 dark:bg-orange-700',
|
||||
bg: 'bg-orange-50 dark:bg-orange-900/20',
|
||||
border: 'border-orange-200 dark:border-orange-800/50',
|
||||
hoverBorder: 'hover:border-orange-400 dark:hover:border-orange-600',
|
||||
tint: 'text-orange-600 dark:text-orange-400',
|
||||
},
|
||||
Midjourney: {
|
||||
accentBg: 'bg-brand-from dark:bg-brand-deep',
|
||||
bg: 'bg-brand/5 dark:bg-brand-deep/20',
|
||||
border: 'border-brand/20 dark:border-brand-deep/50',
|
||||
hoverBorder: 'hover:border-brand-from dark:hover:border-brand-deep',
|
||||
tint: 'text-brand-deep dark:text-brand-from',
|
||||
},
|
||||
default: {
|
||||
accentBg: 'bg-brand-from dark:bg-brand-deep',
|
||||
bg: 'bg-gray-50 dark:bg-neutral-800/50',
|
||||
border: 'border-gray-200 dark:border-neutral-700/50',
|
||||
hoverBorder: 'hover:border-brand-from dark:hover:border-brand-deep',
|
||||
tint: 'text-gray-500 dark:text-gray-400',
|
||||
},
|
||||
};
|
||||
|
||||
const getVendorColors = (vendorName) => {
|
||||
return vendorColors[vendorName] || vendorColors.default;
|
||||
};
|
||||
|
||||
const BentoCard = ({ model, priceData, hidePrice, onClick, onCopy, t }) => {
|
||||
const colors = getVendorColors(model.vendor_name);
|
||||
|
||||
const getModelIcon = (model) => {
|
||||
if (!model) return <Avatar size='small'>?</Avatar>;
|
||||
if (model.icon)
|
||||
return (
|
||||
<div className='w-8 h-8 flex items-center justify-center'>
|
||||
{getLobeHubIcon(model.icon, 24)}
|
||||
</div>
|
||||
);
|
||||
if (model.vendor_icon)
|
||||
return (
|
||||
<div className='w-8 h-8 flex items-center justify-center'>
|
||||
{getLobeHubIcon(model.vendor_icon, 24)}
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<Avatar
|
||||
size='small'
|
||||
style={{
|
||||
backgroundColor: 'var(--brand-primary)',
|
||||
fontSize: 12,
|
||||
}}
|
||||
>
|
||||
{model.model_name?.slice(0, 2).toUpperCase()}
|
||||
</Avatar>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
onClick={onClick}
|
||||
className={`
|
||||
group relative col-span-1 h-auto min-h-[140px]
|
||||
app-card app-card-hover overflow-hidden
|
||||
`}
|
||||
>
|
||||
{/* Top accent line —— 供应商识别色,常驻可见(原 opacity-0 仅 hover 显示,
|
||||
* 改用统一 .app-card 中性边框后会丢失供应商区分,尤其移动端无 hover;
|
||||
* 改为常驻 70%、hover 提到 100% 强化)。 */}
|
||||
<div
|
||||
className={`
|
||||
absolute top-0 left-0 right-0 h-[2px] ${colors.accentBg}
|
||||
opacity-70 group-hover:opacity-100 transition-opacity duration-300
|
||||
`}
|
||||
/>
|
||||
|
||||
{/* ===== 装饰背景层(纯 CSS,pointer-events 关闭,不影响交互) ===== */}
|
||||
{/* 1. 供应商主题色点阵纹理 —— currentColor 取 tint 色,极低透明度只做质感 */}
|
||||
<div
|
||||
aria-hidden='true'
|
||||
className={`absolute inset-0 pointer-events-none ${colors.tint} opacity-[0.05] dark:opacity-[0.07] group-hover:opacity-[0.09] transition-opacity duration-500`}
|
||||
style={{
|
||||
backgroundImage: 'radial-gradient(currentColor 1px, transparent 1px)',
|
||||
backgroundSize: '14px 14px',
|
||||
maskImage: 'linear-gradient(135deg, black 0%, transparent 55%)',
|
||||
WebkitMaskImage: 'linear-gradient(135deg, black 0%, transparent 55%)',
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* 2. 右上角柔光 —— 供应商浅色晕染,hover 时轻微增强 */}
|
||||
<div
|
||||
aria-hidden='true'
|
||||
className={`absolute -top-10 -right-10 w-32 h-32 rounded-full ${colors.bg} blur-2xl opacity-60 group-hover:opacity-100 transition-opacity duration-500 pointer-events-none`}
|
||||
/>
|
||||
|
||||
{/* 3. 右下角供应商图标水印 —— 浅浅的品牌图案 */}
|
||||
{(model.vendor_icon || model.icon) && (
|
||||
<div
|
||||
aria-hidden='true'
|
||||
className='absolute -bottom-5 -right-4 pointer-events-none opacity-[0.06] dark:opacity-[0.08] group-hover:opacity-[0.12] transition-all duration-500 rotate-[-12deg] group-hover:rotate-[-6deg] group-hover:scale-110'
|
||||
>
|
||||
{getLobeHubIcon(model.vendor_icon || model.icon, 88)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className='relative flex-1 p-5 flex flex-col justify-between h-full'>
|
||||
<div className='flex flex-col gap-3'>
|
||||
{/* Header */}
|
||||
<div className='flex items-start justify-between'>
|
||||
<div
|
||||
className={`
|
||||
p-2.5 ${colors.bg} rounded-xl border ${colors.border}
|
||||
transition-transform duration-300
|
||||
group-hover:scale-105
|
||||
`}
|
||||
>
|
||||
{getModelIcon(model)}
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onCopy(model.model_name);
|
||||
}}
|
||||
className='p-1.5 text-gray-400 dark:text-neutral-500 hover:text-brand-deep dark:hover:text-brand-from hover:bg-brand/5 dark:hover:bg-brand-deep/30 rounded-lg transition-colors duration-200'
|
||||
title={t('复制模型名称')}
|
||||
>
|
||||
<Copy size={16} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Model Name */}
|
||||
<h3 className='font-bold text-gray-900 dark:text-white tracking-tight text-base truncate'>
|
||||
{model.model_name}
|
||||
</h3>
|
||||
|
||||
{/* 等级锁态:仅可见(当前等级不可调用) */}
|
||||
{model.level_locked && (
|
||||
<span
|
||||
className='inline-flex items-center gap-1 mt-1 px-2 py-0.5 rounded-md text-[11px] bg-gray-100 dark:bg-neutral-800 text-gray-500 dark:text-neutral-400'
|
||||
title={t('当前等级无权调用此模型,升级等级后可用')}
|
||||
>
|
||||
<Lock size={11} />
|
||||
{t('仅可见')}
|
||||
</span>
|
||||
)}
|
||||
|
||||
{/* Description — show if available */}
|
||||
{model.description && (
|
||||
<p className='text-xs text-gray-500 dark:text-neutral-400 line-clamp-1'>
|
||||
{model.description}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Pricing Tags */}
|
||||
{!hidePrice && (
|
||||
<div className='mt-4 relative'>
|
||||
{/* 折扣徽标:实付价低于管理员维护的官方牌价时出现,
|
||||
* 半浮于价格框上沿,品牌深-主色渐变强调(随主题预设联动,
|
||||
* 深起点保证与卡片浅色品牌纹理拉开对比);加价/未配置官方价时不渲染 */}
|
||||
{getDiscountBadgeText(priceData) && (
|
||||
<span
|
||||
className='absolute -top-2.5 right-3 z-10 px-2 py-0.5 rounded-full
|
||||
text-[11px] font-bold text-white leading-4
|
||||
bg-gradient-to-r from-brand-deep to-brand
|
||||
shadow-md shadow-brand/30 select-none'
|
||||
title={t(
|
||||
'相比官方牌价的折扣,按当前计价分组实付价计算(已含您的等级折扣),仅供参考',
|
||||
)}
|
||||
>
|
||||
{getDiscountBadgeText(priceData)}
|
||||
</span>
|
||||
)}
|
||||
<div
|
||||
className={`
|
||||
px-3 py-2.5
|
||||
bg-gray-50/80 dark:bg-neutral-800/60
|
||||
rounded-xl border border-gray-200/50 dark:border-neutral-700/50
|
||||
text-xs font-mono text-gray-600 dark:text-neutral-300
|
||||
flex flex-col gap-1
|
||||
`}
|
||||
>
|
||||
{formatPriceInfo(priceData, t)}
|
||||
{/* 计价分组标注:明确该价格按哪个分组倍率计算,
|
||||
* 消除「最优倍率视图」下与实际账单分组不一致的歧义 */}
|
||||
{priceData?.usedGroup && (
|
||||
<span
|
||||
className='text-[10px] leading-4 font-sans'
|
||||
style={{ color: 'var(--semi-color-text-3)' }}
|
||||
title={t('该价格按 {{group}} 分组倍率计算', {
|
||||
group: priceData.usedGroup,
|
||||
})}
|
||||
>
|
||||
{t('按 {{group}} 分组计价', { group: priceData.usedGroup })}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(BentoCard);
|
||||
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
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, { useMemo, useRef, useEffect, useState } from 'react';
|
||||
import { calculateModelPrice, getLobeHubIcon } from '../../../../helpers';
|
||||
import BentoCard from './BentoCard';
|
||||
import { Empty } from '@douyinfe/semi-ui';
|
||||
import {
|
||||
IllustrationNoResult,
|
||||
IllustrationNoResultDark,
|
||||
} from '../../../common/illustrations';
|
||||
import { Layers } from 'lucide-react';
|
||||
|
||||
// Vendor accent colors for section headers
|
||||
const vendorAccents = {
|
||||
OpenAI: 'from-emerald-500 to-teal-500',
|
||||
Anthropic: 'from-amber-500 to-orange-500',
|
||||
Google: 'from-blue-500 to-brand-to',
|
||||
Meta: 'from-blue-600 to-blue-700',
|
||||
Mistral: 'from-orange-500 to-red-500',
|
||||
Midjourney: 'from-brand-from to-brand-to',
|
||||
default: 'from-brand-from to-brand-to',
|
||||
};
|
||||
|
||||
const getVendorAccent = (vendor) =>
|
||||
vendorAccents[vendor] || vendorAccents.default;
|
||||
|
||||
// Skeleton card for loading state
|
||||
const SkeletonCard = () => (
|
||||
<div className='app-card overflow-hidden min-h-[140px] animate-pulse'>
|
||||
<div className='p-5 flex flex-col gap-3'>
|
||||
<div className='flex items-start justify-between'>
|
||||
<div className='w-12 h-12 bg-gray-200 dark:bg-neutral-700 rounded-xl' />
|
||||
<div className='w-6 h-6 bg-gray-200 dark:bg-neutral-700 rounded-lg' />
|
||||
</div>
|
||||
<div className='w-3/4 h-5 bg-gray-200 dark:bg-neutral-700 rounded-lg' />
|
||||
<div className='mt-2 px-3 py-3 bg-gray-100 dark:bg-neutral-800 rounded-xl'>
|
||||
<div className='w-full h-3 bg-gray-200 dark:bg-neutral-700 rounded mb-2' />
|
||||
<div className='w-2/3 h-3 bg-gray-200 dark:bg-neutral-700 rounded' />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
// Hook: observe element visibility via IntersectionObserver
|
||||
const useInView = (options = {}) => {
|
||||
const ref = useRef(null);
|
||||
const [inView, setInView] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const el = ref.current;
|
||||
if (!el) return;
|
||||
const observer = new IntersectionObserver(
|
||||
([entry]) => {
|
||||
if (entry.isIntersecting) {
|
||||
setInView(true);
|
||||
observer.disconnect(); // only trigger once
|
||||
}
|
||||
},
|
||||
{ rootMargin: '200px 0px', ...options },
|
||||
);
|
||||
observer.observe(el);
|
||||
return () => observer.disconnect();
|
||||
}, []);
|
||||
|
||||
return [ref, inView];
|
||||
};
|
||||
|
||||
const BentoGrid = ({
|
||||
filteredModels,
|
||||
loading,
|
||||
selectedGroup,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
currency,
|
||||
hidePrice,
|
||||
t,
|
||||
copyText,
|
||||
openModelDetail,
|
||||
}) => {
|
||||
// Group models by Vendor for sections
|
||||
const sections = useMemo(() => {
|
||||
if (!filteredModels) return [];
|
||||
|
||||
const groups = {};
|
||||
|
||||
filteredModels.forEach((model) => {
|
||||
const vendor = model.vendor_name || 'Others';
|
||||
if (!groups[vendor]) {
|
||||
groups[vendor] = [];
|
||||
}
|
||||
groups[vendor].push(model);
|
||||
});
|
||||
|
||||
// Sort keys with priority vendors first
|
||||
const sortedKeys = Object.keys(groups).sort((a, b) => {
|
||||
const priority = ['OpenAI', 'Anthropic', 'Google', 'Midjourney'];
|
||||
const idxA = priority.indexOf(a);
|
||||
const idxB = priority.indexOf(b);
|
||||
if (idxA !== -1 && idxB !== -1) return idxA - idxB;
|
||||
if (idxA !== -1) return -1;
|
||||
if (idxB !== -1) return 1;
|
||||
return a.localeCompare(b);
|
||||
});
|
||||
|
||||
return sortedKeys.map((key) => ({
|
||||
title: key,
|
||||
models: groups[key],
|
||||
}));
|
||||
}, [filteredModels]);
|
||||
|
||||
// Loading skeleton state
|
||||
if (loading) {
|
||||
return (
|
||||
<div className='container mx-auto px-6 py-6 pb-20'>
|
||||
{[1, 2].map((sectionIdx) => (
|
||||
<div key={sectionIdx} className='mb-10'>
|
||||
{/* Skeleton section header */}
|
||||
<div className='flex items-center gap-4 mb-5'>
|
||||
<div className='w-10 h-10 bg-gray-200 dark:bg-neutral-700 rounded-xl animate-pulse' />
|
||||
<div className='w-32 h-6 bg-gray-200 dark:bg-neutral-700 rounded-lg animate-pulse' />
|
||||
<div className='flex-1 h-px bg-gray-200 dark:bg-neutral-700' />
|
||||
<div className='w-16 h-7 bg-gray-200 dark:bg-neutral-700 rounded-full animate-pulse' />
|
||||
</div>
|
||||
<div className='grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-5'>
|
||||
{Array.from({ length: 8 }).map((_, i) => (
|
||||
<SkeletonCard key={i} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (filteredModels.length === 0) {
|
||||
return (
|
||||
<div className='flex flex-col items-center justify-center py-32'>
|
||||
<div className='relative'>
|
||||
<div className='absolute inset-0 bg-gradient-to-r from-brand-from/10 to-brand-to/10 blur-3xl rounded-full' />
|
||||
<Empty
|
||||
image={<IllustrationNoResult style={{ width: 180, height: 180 }} />}
|
||||
darkModeImage={
|
||||
<IllustrationNoResultDark style={{ width: 180, height: 180 }} />
|
||||
}
|
||||
description={
|
||||
<span className='text-gray-500 dark:text-neutral-400 font-medium mt-4 block'>
|
||||
{t('No models found')}
|
||||
</span>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='container mx-auto px-6 py-6 pb-20'>
|
||||
{sections.map((section, sectionIndex) => (
|
||||
<VendorSection
|
||||
key={section.title}
|
||||
section={section}
|
||||
sectionIndex={sectionIndex}
|
||||
selectedGroup={selectedGroup}
|
||||
groupRatio={groupRatio}
|
||||
groupModelDiscount={groupModelDiscount}
|
||||
tokenUnit={tokenUnit}
|
||||
displayPrice={displayPrice}
|
||||
currency={currency}
|
||||
hidePrice={hidePrice}
|
||||
t={t}
|
||||
copyText={copyText}
|
||||
openModelDetail={openModelDetail}
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* CSS for animations */}
|
||||
<style>{`
|
||||
@keyframes fadeInUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(12px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// Lazy-rendered vendor section — only renders cards when scrolled into view
|
||||
const VendorSection = React.memo(
|
||||
({
|
||||
section,
|
||||
sectionIndex,
|
||||
selectedGroup,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
currency,
|
||||
hidePrice,
|
||||
t,
|
||||
copyText,
|
||||
openModelDetail,
|
||||
}) => {
|
||||
const [sectionRef, isInView] = useInView();
|
||||
const accent = getVendorAccent(section.title);
|
||||
// 分组标题优先展示真实供应商 logo(取该组任一模型的 vendor_icon),
|
||||
// 没有时回退到原来的渐变通用图标
|
||||
const vendorIcon = section.models.find((m) => m.vendor_icon)?.vendor_icon;
|
||||
|
||||
return (
|
||||
<div ref={sectionRef} className='mb-10'>
|
||||
{/* Section Header */}
|
||||
<div className='flex items-center gap-4 mb-5'>
|
||||
{vendorIcon ? (
|
||||
<div className='p-2.5 rounded-xl bg-white/80 dark:bg-neutral-800/80 backdrop-blur-sm border border-gray-200/60 dark:border-neutral-700/60 shadow-sm'>
|
||||
<div className='w-5 h-5 flex items-center justify-center'>
|
||||
{getLobeHubIcon(vendorIcon, 20)}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
className={`p-2.5 rounded-xl bg-gradient-to-br ${accent} shadow-lg shadow-brand/20`}
|
||||
>
|
||||
<Layers size={20} className='text-white' />
|
||||
</div>
|
||||
)}
|
||||
|
||||
<h2 className='text-2xl font-bold text-gray-900 dark:text-white tracking-tight'>
|
||||
{section.title}
|
||||
</h2>
|
||||
|
||||
<div className='flex-1 h-px bg-gradient-to-r from-gray-200 via-gray-300/50 to-transparent dark:from-neutral-700 dark:via-neutral-800/50 dark:to-transparent' />
|
||||
|
||||
<div className='flex items-center gap-2'>
|
||||
<span
|
||||
className={`text-sm font-bold font-mono px-3 py-1.5 rounded-full bg-gradient-to-r ${accent} text-white shadow-md`}
|
||||
>
|
||||
{section.models.length}
|
||||
</span>
|
||||
<span className='text-sm text-gray-500 dark:text-neutral-400 font-medium'>
|
||||
{t('MODELS')}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Cards Grid — render skeletons when not in view */}
|
||||
<div className='grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-5'>
|
||||
{isInView
|
||||
? section.models.map((model, index) => {
|
||||
const priceData = calculateModelPrice({
|
||||
record: model,
|
||||
selectedGroup,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
currency,
|
||||
});
|
||||
|
||||
// Cap animation delay at 600ms so cards never stay invisible too long
|
||||
const delay = Math.min(index * 40, 600);
|
||||
|
||||
return (
|
||||
<div
|
||||
key={model.key || index}
|
||||
style={{
|
||||
animationDelay: `${delay}ms`,
|
||||
animation: 'fadeInUp 0.35s ease-out forwards',
|
||||
opacity: 0,
|
||||
}}
|
||||
>
|
||||
<BentoCard
|
||||
model={model}
|
||||
priceData={priceData}
|
||||
hidePrice={hidePrice}
|
||||
t={t}
|
||||
onClick={() => openModelDetail(model)}
|
||||
onCopy={copyText}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
})
|
||||
: // Placeholder skeleton cards when section is not yet visible
|
||||
Array.from({ length: Math.min(section.models.length, 8) }).map(
|
||||
(_, i) => <SkeletonCard key={i} />,
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
VendorSection.displayName = 'VendorSection';
|
||||
|
||||
export default BentoGrid;
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
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, { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import { Search, Sparkles } from 'lucide-react';
|
||||
|
||||
const BentoHero = ({ searchValue, setSearchValue, t }) => {
|
||||
// Debounced search: local state for instant typing feedback, debounced propagation
|
||||
const [localSearch, setLocalSearch] = useState(searchValue);
|
||||
const debounceTimer = useRef(null);
|
||||
|
||||
// Sync external value → local (e.g. if cleared by parent)
|
||||
// Also clear any pending debounce to avoid overriding the external change
|
||||
useEffect(() => {
|
||||
setLocalSearch(searchValue);
|
||||
if (debounceTimer.current) {
|
||||
clearTimeout(debounceTimer.current);
|
||||
debounceTimer.current = null;
|
||||
}
|
||||
}, [searchValue]);
|
||||
|
||||
const handleSearchChange = useCallback(
|
||||
(e) => {
|
||||
const value = e.target.value;
|
||||
setLocalSearch(value);
|
||||
|
||||
// Debounce: propagate to parent after 300ms of no typing
|
||||
if (debounceTimer.current) clearTimeout(debounceTimer.current);
|
||||
debounceTimer.current = setTimeout(() => {
|
||||
setSearchValue(value);
|
||||
}, 300);
|
||||
},
|
||||
[setSearchValue],
|
||||
);
|
||||
|
||||
// Cleanup timer on unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (debounceTimer.current) clearTimeout(debounceTimer.current);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className='relative w-full pt-16 md:pt-20 pb-8 px-6 flex flex-col items-center justify-center text-center z-10 overflow-hidden'>
|
||||
{/* Lightweight decorative elements */}
|
||||
<div className='absolute inset-0 overflow-hidden pointer-events-none'>
|
||||
<Sparkles className='absolute top-20 left-[15%] w-6 h-6 text-brand-via/40 dark:text-brand-via/25' />
|
||||
<Sparkles className='absolute top-32 right-[20%] w-4 h-4 text-brand-from/30 dark:text-brand-from/20' />
|
||||
{/* Aurora 柔光斑 —— 纯 CSS 装饰,营造氛围;色相全部取品牌渐变三段,随主题预设联动 */}
|
||||
<div className='absolute -top-24 left-[8%] w-72 h-72 rounded-full bg-brand-from/10 dark:bg-brand-from/[0.07] blur-3xl' />
|
||||
<div className='absolute -top-16 right-[5%] w-80 h-80 rounded-full bg-brand-to/10 dark:bg-brand-to/[0.06] blur-3xl' />
|
||||
<div className='absolute top-24 left-[45%] w-56 h-56 rounded-full bg-brand-via/10 dark:bg-brand-via/[0.05] blur-3xl' />
|
||||
</div>
|
||||
|
||||
{/* Badge chip */}
|
||||
<div className='relative mb-5'>
|
||||
<span className='inline-flex items-center gap-1.5 px-4 py-1.5 rounded-full text-xs font-semibold tracking-wide uppercase bg-white/70 dark:bg-neutral-900/70 backdrop-blur-sm border border-brand-from/30 dark:border-brand-from/20 text-brand-deep dark:text-brand-from shadow-sm shadow-brand/10'>
|
||||
<Sparkles className='w-3.5 h-3.5' />
|
||||
{t('模型超市')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Title */}
|
||||
<h1 className='text-4xl md:text-6xl font-extrabold tracking-tight mb-4'>
|
||||
<span className='bg-clip-text text-transparent bg-gradient-to-r from-brand-from via-brand-via to-brand-to'>
|
||||
{t('Search available models')}
|
||||
</span>
|
||||
</h1>
|
||||
|
||||
{/* Subtitle */}
|
||||
<p className='max-w-xl text-sm md:text-base text-gray-500 dark:text-neutral-400 mb-6'>
|
||||
{t('一站式浏览、比价与接入各大 AI 模型')}
|
||||
</p>
|
||||
|
||||
{/* Search Input — simplified, fewer layers */}
|
||||
<div className='relative w-full max-w-2xl group'>
|
||||
<div className='relative flex items-center bg-white/80 dark:bg-neutral-900/80 backdrop-blur-xl border border-gray-200/80 dark:border-neutral-700/50 rounded-full overflow-hidden shadow-lg shadow-gray-200/50 dark:shadow-black/30 transition-all duration-300 focus-within:border-brand-from dark:focus-within:border-brand focus-within:shadow-xl focus-within:shadow-brand/20 dark:focus-within:shadow-brand-deep/20'>
|
||||
<div className='pl-6 text-gray-400 dark:text-neutral-500 group-focus-within:text-brand dark:group-focus-within:text-brand-from transition-colors duration-300'>
|
||||
<Search size={22} />
|
||||
</div>
|
||||
<input
|
||||
type='text'
|
||||
className='w-full bg-transparent border-none py-4 px-4 pr-6 text-lg text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-0'
|
||||
placeholder={t('Search models...')}
|
||||
value={localSearch}
|
||||
onChange={handleSearchChange}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Status hint */}
|
||||
<p className='mt-4 text-sm text-gray-500 dark:text-neutral-500 font-medium'>
|
||||
<span className='inline-flex items-center gap-1.5'>
|
||||
<span className='w-2 h-2 bg-brand rounded-full animate-pulse' />
|
||||
{t('实时更新')}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default BentoHero;
|
||||
@@ -0,0 +1,295 @@
|
||||
/*
|
||||
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, { useRef, useState, useEffect } from 'react';
|
||||
import { Button, Select } from '@douyinfe/semi-ui';
|
||||
import { IconFilter } from '@douyinfe/semi-icons';
|
||||
import { ChevronDown } from 'lucide-react';
|
||||
import { getLobeHubIcon } from '../../../../helpers';
|
||||
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
|
||||
|
||||
// 供应商 pill 折叠态的单行高度(px):pill 高约 38px,留 6px 余量。
|
||||
// 超过该高度说明 pill 折行了,此时才显示「展开/收起」按钮
|
||||
const COLLAPSED_ROW_HEIGHT = 44;
|
||||
|
||||
const FilterBar = ({
|
||||
vendorsMap,
|
||||
filterVendor,
|
||||
setFilterVendor,
|
||||
filterGroup,
|
||||
setFilterGroup,
|
||||
groupCountModels,
|
||||
groupRatio,
|
||||
autoGroups,
|
||||
showRatio,
|
||||
onOpenDrawer,
|
||||
t,
|
||||
models, // filtered models for counts
|
||||
allModels = [], // 完整模型列表(未经筛选),用于判断供应商下是否有可用模型
|
||||
}) => {
|
||||
// 手机端不走「折叠一行 + 展开」这套:窄屏下 9 个供应商展开后是 5 行 pill 墙,
|
||||
// 把首屏内容整个推下去。改为主流移动端做法——单行横向滚动 chip 条。
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
// 供应商较多时折为一行 + 展开按钮,避免长横向滚动难以浏览
|
||||
const vendorRowRef = useRef(null);
|
||||
const [vendorsExpanded, setVendorsExpanded] = useState(false);
|
||||
const [vendorsOverflow, setVendorsOverflow] = useState(false);
|
||||
|
||||
// 供应商下没有任何可用模型时不展示该供应商(vendorsMap 返回的是全部供应商记录,
|
||||
// 模型可能被等级策略/渠道下线剔除,须以实际模型列表为准)
|
||||
const availableVendorNames = React.useMemo(() => {
|
||||
const names = new Set();
|
||||
(allModels || []).forEach((m) => {
|
||||
if (m.vendor_name) names.add(m.vendor_name);
|
||||
});
|
||||
return names;
|
||||
}, [allModels]);
|
||||
|
||||
// Prepare Vendor List
|
||||
const vendorsList = Object.values(vendorsMap || {})
|
||||
.filter((vendor) => availableVendorNames.has(vendor.name))
|
||||
.sort((a, b) => a.name.localeCompare(b.name));
|
||||
|
||||
// 折叠态下把当前选中的供应商提到最前,避免选中 pill 折行到
|
||||
// 被隐藏的第二行后用户看不到当前生效的筛选项;展开态保持字母序
|
||||
// 手机端横向滚动条不做提序:点击后 chip 会跳到行首,手指下的元素位移,体感很糟
|
||||
const selectedIdx =
|
||||
!isMobile && !vendorsExpanded && filterVendor !== 'all'
|
||||
? vendorsList.findIndex((v) => v.name === filterVendor)
|
||||
: -1;
|
||||
const displayVendors =
|
||||
selectedIdx > 0
|
||||
? [
|
||||
vendorsList[selectedIdx],
|
||||
...vendorsList.slice(0, selectedIdx),
|
||||
...vendorsList.slice(selectedIdx + 1),
|
||||
]
|
||||
: vendorsList;
|
||||
|
||||
// 检测供应商 pill 是否折行(窗口尺寸/供应商列表变化时重新计算),
|
||||
// 只有确实放不下一行时才渲染「展开」按钮。
|
||||
// 依赖「显示顺序的名称串」而非 length:折叠态容器盒尺寸被 max-height 钳住,
|
||||
// 内容变化(名称宽度、选中项提序导致的排布变化)不会触发 ResizeObserver,
|
||||
// 需靠依赖项重算
|
||||
const vendorNamesKey = displayVendors.map((v) => v.name).join('|');
|
||||
useEffect(() => {
|
||||
// 手机端是横向滚动,不存在折行,无需测高(也避免 max-height 钳制误判)
|
||||
if (isMobile) {
|
||||
setVendorsOverflow(false);
|
||||
return;
|
||||
}
|
||||
const el = vendorRowRef.current;
|
||||
if (!el) return;
|
||||
const check = () =>
|
||||
setVendorsOverflow(el.scrollHeight > COLLAPSED_ROW_HEIGHT + 4);
|
||||
check();
|
||||
const observer = new ResizeObserver(check);
|
||||
observer.observe(el);
|
||||
return () => observer.disconnect();
|
||||
}, [vendorNamesKey, isMobile]);
|
||||
|
||||
// Prepare Groups for Select
|
||||
const groupOptions = [
|
||||
{ value: 'all', label: t('全部分组'), otherKey: 'View' },
|
||||
...autoGroups.map((g) => ({ value: g, label: g, type: 'auto' })),
|
||||
...Object.keys(groupRatio).map((g) => ({
|
||||
value: g,
|
||||
label: g,
|
||||
type: 'custom',
|
||||
})),
|
||||
].filter((v, i, a) => a.findIndex((t) => t.value === v.value) === i); // Deduplicate
|
||||
|
||||
return (
|
||||
// 吸顶位置必须让开固定顶栏:滚动容器从视口 y=0 开始,写 top-0 会让整条筛选栏
|
||||
// (手机端是 flex-col,供应商横滑条在第一行)吸到顶栏底下被完全盖住,
|
||||
// 用户得一路滚回页首才能碰到筛选。--app-header-height 由 PageLayout 发布,
|
||||
// 已包含跑马灯高度。
|
||||
<div
|
||||
className='sticky z-40 w-full transition-all duration-300'
|
||||
style={{ top: 'var(--app-header-height, 0px)' }}
|
||||
>
|
||||
{/* Glassmorphism background —— 中央高不透明保证 sticky 吸顶时 pill 可读,
|
||||
* 两翼渐隐融入页面背景,消除宽屏下横贯全屏的生硬纯白色带 */}
|
||||
<div className='absolute inset-0 backdrop-blur-xl bg-gradient-to-r from-white/30 via-white/80 to-white/30 dark:from-neutral-900/40 dark:via-neutral-900/85 dark:to-neutral-900/40' />
|
||||
|
||||
{/* 品牌色晕染层:两翼各一枚低透明度光斑 + 贯穿的极淡品牌渐变,
|
||||
* 给横带罩上一层主题色氛围(全部 token 派生,随预设/暗色联动) */}
|
||||
<div className='absolute inset-0 overflow-hidden pointer-events-none'>
|
||||
<div className='absolute inset-0 bg-gradient-to-r from-brand-from/[0.07] via-transparent to-brand-to/[0.07]' />
|
||||
<div className='absolute -left-12 -top-20 w-64 h-64 rounded-full bg-brand-from/10 dark:bg-brand-from/[0.08] blur-3xl' />
|
||||
<div className='absolute -right-12 -top-20 w-64 h-64 rounded-full bg-brand-to/10 dark:bg-brand-to/[0.08] blur-3xl' />
|
||||
</div>
|
||||
|
||||
{/* 上下发丝线:顶部极淡、底部稍强的品牌渐变,替代原来的灰色底边框 */}
|
||||
<div className='absolute top-0 left-0 right-0 h-[1px] bg-gradient-to-r from-transparent via-brand-via/15 to-transparent' />
|
||||
<div className='absolute bottom-0 left-0 right-0 h-[1px] bg-gradient-to-r from-transparent via-brand-via/35 to-transparent' />
|
||||
|
||||
<div className='relative container mx-auto px-4 md:px-6 py-3'>
|
||||
<div className='flex flex-col md:flex-row items-center justify-between gap-3 md:gap-4'>
|
||||
{/* Left: Vendor pills —— 桌面端折叠为一行可展开;手机端单行横向滚动 */}
|
||||
<div className='flex-1 w-full md:w-auto flex items-start gap-2 min-w-0'>
|
||||
<div
|
||||
ref={vendorRowRef}
|
||||
className={
|
||||
isMobile
|
||||
? // 负外边距让 chip 条通栏,右侧被裁的半个 chip 就是「可横滑」的视觉提示;
|
||||
// scroll-snap 让手指松开后停在 chip 边界而不是半个字上
|
||||
'flex-1 min-w-0 flex flex-nowrap items-center gap-2 overflow-x-auto scrollbar-hide snap-x scroll-pl-4 -mx-4 px-4 py-0.5 overscroll-x-contain'
|
||||
: 'flex-1 flex flex-wrap items-center gap-2 overflow-hidden transition-[max-height] duration-300'
|
||||
}
|
||||
style={
|
||||
isMobile
|
||||
? undefined
|
||||
: {
|
||||
// 展开上限只为 max-height 过渡动画服务,取一个大到不会截断真实内容的值
|
||||
// (~1500px 约可容纳 30+ 行 pill;超出属极端配置,此时下方内容仍可正常滚动)
|
||||
maxHeight: vendorsExpanded
|
||||
? '1500px'
|
||||
: `${COLLAPSED_ROW_HEIGHT}px`,
|
||||
}
|
||||
}
|
||||
>
|
||||
{/* All Vendors Button */}
|
||||
<button
|
||||
onClick={() => setFilterVendor('all')}
|
||||
className={`
|
||||
flex-shrink-0 snap-start rounded-full font-semibold
|
||||
px-3 py-1.5 text-[13px] md:px-4 md:py-2 md:text-sm
|
||||
transition-all duration-300 transform md:hover:scale-105
|
||||
${
|
||||
filterVendor === 'all'
|
||||
? 'bg-gradient-to-r from-brand-from via-brand-via to-brand-to text-white shadow-lg shadow-brand/25'
|
||||
: 'bg-gray-100/80 dark:bg-neutral-800/80 text-gray-600 dark:text-gray-300 hover:bg-gray-200/80 dark:hover:bg-neutral-700/80 border border-gray-200/50 dark:border-neutral-700/50'
|
||||
}
|
||||
`}
|
||||
>
|
||||
{t('全部供应商')}
|
||||
{vendorsList.length > 0 && (
|
||||
<span
|
||||
className={`ml-1.5 text-xs font-mono ${
|
||||
filterVendor === 'all'
|
||||
? 'text-white/80'
|
||||
: 'text-gray-400 dark:text-neutral-500'
|
||||
}`}
|
||||
>
|
||||
{vendorsList.length}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
|
||||
{displayVendors.map((vendor) => {
|
||||
const isActive = filterVendor === vendor.name;
|
||||
return (
|
||||
<button
|
||||
key={vendor.id}
|
||||
onClick={() => setFilterVendor(vendor.name)}
|
||||
className={`
|
||||
flex-shrink-0 snap-start flex items-center rounded-full font-medium
|
||||
gap-1.5 px-3 py-1.5 text-[13px] md:gap-2 md:px-4 md:py-2 md:text-sm
|
||||
transition-all duration-300 transform md:hover:scale-105 border
|
||||
${
|
||||
isActive
|
||||
? 'border-brand-from bg-brand/5 dark:bg-brand-deep/30 text-brand-deep dark:text-brand-from shadow-md shadow-brand/10'
|
||||
: 'border-gray-200/50 dark:border-neutral-700/50 bg-gray-100/80 dark:bg-neutral-800/80 text-gray-600 dark:text-gray-300 hover:bg-gray-200/80 dark:hover:bg-neutral-700/80 hover:border-gray-300 dark:hover:border-neutral-600'
|
||||
}
|
||||
`}
|
||||
>
|
||||
{vendor.icon && (
|
||||
<div className='w-4 h-4 flex items-center justify-center transition-transform group-hover:scale-110'>
|
||||
{getLobeHubIcon(vendor.icon, 16)}
|
||||
</div>
|
||||
)}
|
||||
<span className='whitespace-nowrap'>{vendor.name}</span>
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* 展开/收起按钮 —— 仅桌面端、且 pill 确实折行(供应商较多)时出现 */}
|
||||
{!isMobile && (vendorsOverflow || vendorsExpanded) && (
|
||||
<button
|
||||
onClick={() => setVendorsExpanded((v) => !v)}
|
||||
className='flex-shrink-0 flex items-center gap-1 px-3 py-2 rounded-full text-sm font-medium border border-dashed border-gray-300 dark:border-neutral-600 text-gray-500 dark:text-gray-400 hover:text-brand-deep dark:hover:text-brand-from hover:border-brand-from/60 hover:bg-brand/5 dark:hover:bg-brand-deep/20 transition-all duration-300'
|
||||
title={vendorsExpanded ? t('收起') : t('展开')}
|
||||
>
|
||||
<span>{vendorsExpanded ? t('收起') : t('展开')}</span>
|
||||
<ChevronDown
|
||||
size={14}
|
||||
className={`transition-transform duration-300 ${
|
||||
vendorsExpanded ? 'rotate-180' : ''
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Right: Group Selector & Advanced Filter */}
|
||||
<div className='flex items-center gap-2 md:gap-3 flex-shrink-0 w-full md:w-auto'>
|
||||
{/* Group Selector with glassmorphism —— 手机端与「更多」平分一行,撑满可用宽度 */}
|
||||
<div className='flex flex-1 md:flex-none items-center gap-2 min-w-0 bg-gray-100/80 dark:bg-neutral-800/80 backdrop-blur-sm rounded-xl p-1.5 border border-gray-200/50 dark:border-neutral-700/50'>
|
||||
<span className='text-xs font-bold text-gray-500 dark:text-gray-400 pl-2 uppercase hidden sm:block tracking-wider'>
|
||||
{t('分组')}
|
||||
</span>
|
||||
<Select
|
||||
value={filterGroup}
|
||||
onChange={setFilterGroup}
|
||||
style={{
|
||||
width: isMobile ? '100%' : 150,
|
||||
border: 'none',
|
||||
backgroundColor: 'transparent',
|
||||
}}
|
||||
dropdownClassName='dark:bg-neutral-800 backdrop-blur-xl'
|
||||
size='small'
|
||||
optionList={groupOptions.map((g) => ({
|
||||
value: g.value,
|
||||
label: (
|
||||
<div className='flex justify-between items-center w-full'>
|
||||
<span className='font-medium'>{g.label}</span>
|
||||
{showRatio && groupRatio[g.value] && (
|
||||
<span className='text-brand dark:text-brand-from text-xs font-mono ml-2 bg-brand/5 dark:bg-brand-deep/30 px-1.5 py-0.5 rounded'>
|
||||
x{groupRatio[g.value]}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Divider */}
|
||||
<div className='w-px h-6 bg-gradient-to-b from-transparent via-gray-300 dark:via-neutral-600 to-transparent hidden md:block' />
|
||||
|
||||
{/* Filter Drawer Trigger with gradient hover */}
|
||||
<Button
|
||||
icon={<IconFilter />}
|
||||
theme='solid'
|
||||
type='tertiary'
|
||||
className='!flex-shrink-0 !bg-gray-100/80 dark:!bg-neutral-800/80 !text-gray-700 dark:!text-gray-200 hover:!bg-gradient-to-r hover:!from-brand-from hover:!via-brand-via hover:!to-brand-to hover:!text-white !border !border-gray-200/50 dark:!border-neutral-700/50 hover:!border-transparent !transition-all !duration-300 !rounded-xl'
|
||||
onClick={onOpenDrawer}
|
||||
>
|
||||
{t('更多')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default FilterBar;
|
||||
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
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 { SideSheet, Button } from '@douyinfe/semi-ui';
|
||||
import {
|
||||
Filter,
|
||||
Users,
|
||||
CreditCard,
|
||||
Tag,
|
||||
Layers,
|
||||
X,
|
||||
Sparkles,
|
||||
} from 'lucide-react';
|
||||
import PricingTags from '../filter/PricingTags';
|
||||
import PricingQuotaTypes from '../filter/PricingQuotaTypes';
|
||||
import PricingEndpointTypes from '../filter/PricingEndpointTypes';
|
||||
import PricingGroups from '../filter/PricingGroups';
|
||||
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
|
||||
|
||||
const FilterDrawer = ({
|
||||
visible,
|
||||
onClose,
|
||||
t,
|
||||
filterTag,
|
||||
setFilterTag,
|
||||
filterQuotaType,
|
||||
setFilterQuotaType,
|
||||
filterEndpointType,
|
||||
setFilterEndpointType,
|
||||
filterGroup,
|
||||
setFilterGroup,
|
||||
autoGroups,
|
||||
usableGroup = {},
|
||||
endpointMap,
|
||||
groupRatio,
|
||||
showRatio = true,
|
||||
allModels,
|
||||
tagModels,
|
||||
quotaTypeModels,
|
||||
endpointTypeModels,
|
||||
groupCountModels,
|
||||
}) => {
|
||||
// 380px 在 390px 视口上只剩一条 10px 缝,既不好看也点不中遮罩关闭,手机端直接铺满
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
return (
|
||||
<SideSheet
|
||||
title={null}
|
||||
headerStyle={{ display: 'none' }}
|
||||
visible={visible}
|
||||
onCancel={onClose}
|
||||
width={isMobile ? '100%' : 380}
|
||||
maskStyle={{
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
||||
backdropFilter: 'blur(4px)',
|
||||
}}
|
||||
bodyStyle={{
|
||||
padding: '0',
|
||||
background: 'var(--semi-color-bg-0)',
|
||||
}}
|
||||
disableScroll={false}
|
||||
>
|
||||
{/* 自定义头部 */}
|
||||
<div className='relative bg-white dark:bg-neutral-900'>
|
||||
{/* 顶部装饰线 */}
|
||||
<div className='absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-brand-from via-brand-via to-brand-to' />
|
||||
|
||||
{/* 头部内容 */}
|
||||
<div className='relative px-6 py-5 pt-6'>
|
||||
<div className='flex items-center justify-between'>
|
||||
<div className='flex items-center gap-3'>
|
||||
<div className='relative'>
|
||||
<div className='absolute -inset-1 bg-gradient-to-br from-brand-from/40 to-brand-to/40 rounded-xl blur-md' />
|
||||
<div className='relative p-2.5 bg-gradient-to-br from-brand-from to-brand-to rounded-xl shadow-lg'>
|
||||
<Filter size={20} className='text-white' />
|
||||
</div>
|
||||
<Sparkles
|
||||
size={12}
|
||||
className='absolute -top-1 -right-1 text-brand-via'
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<h2 className='text-lg font-bold bg-clip-text text-transparent bg-gradient-to-r from-brand-from to-brand-to dark:from-brand-from dark:to-brand-to'>
|
||||
{t('显示设置')}
|
||||
</h2>
|
||||
<p className='text-xs text-gray-500 dark:text-gray-400 mt-0.5'>
|
||||
{t('筛选并精确查找模型')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 关闭按钮 */}
|
||||
<button
|
||||
onClick={onClose}
|
||||
className='p-2 rounded-xl bg-gray-100/80 hover:bg-gray-200/80 dark:bg-neutral-800/80 dark:hover:bg-neutral-700/80 transition-all duration-200 hover:scale-105 group'
|
||||
>
|
||||
<X
|
||||
size={18}
|
||||
className='text-gray-500 group-hover:text-gray-700 dark:text-gray-400 dark:group-hover:text-gray-200'
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 分隔线 */}
|
||||
<div className='h-px bg-gradient-to-r from-transparent via-brand-via/20 dark:via-brand-via to-transparent mx-4' />
|
||||
|
||||
{/* 筛选内容 —— 分区卡片:单一标题行(内置组件标题传 null 隐藏,避免双标题)、
|
||||
* 浅色品牌 chip 替代整列实色渐变块,视觉更克制(云控制台惯例) */}
|
||||
<div className='flex-1 overflow-y-auto px-5 py-5 bg-gray-50 dark:bg-neutral-900 app-scrollbar'>
|
||||
<div className='space-y-3'>
|
||||
{/* 用户分组 */}
|
||||
<section className='bg-white dark:bg-neutral-900 rounded-xl px-4 pt-3 pb-2 border border-gray-100 dark:border-neutral-800 shadow-sm [&>*:last-child]:!mb-0'>
|
||||
<div className='flex items-center gap-2 mb-2.5'>
|
||||
<div className='w-7 h-7 rounded-lg bg-brand/10 dark:bg-brand-deep/30 flex items-center justify-center'>
|
||||
<Users
|
||||
size={14}
|
||||
className='text-brand-deep dark:text-brand-from'
|
||||
/>
|
||||
</div>
|
||||
<h3 className='text-sm font-semibold text-gray-800 dark:text-gray-200'>
|
||||
{t('用户分组')}
|
||||
</h3>
|
||||
</div>
|
||||
<PricingGroups
|
||||
filterGroup={filterGroup}
|
||||
setFilterGroup={setFilterGroup}
|
||||
groupRatio={groupRatio}
|
||||
usableGroup={usableGroup}
|
||||
showRatio={showRatio}
|
||||
t={t}
|
||||
models={groupCountModels}
|
||||
title={null}
|
||||
/>
|
||||
</section>
|
||||
|
||||
{/* 计费类型 */}
|
||||
<section className='bg-white dark:bg-neutral-900 rounded-xl px-4 pt-3 pb-2 border border-gray-100 dark:border-neutral-800 shadow-sm [&>*:last-child]:!mb-0'>
|
||||
<div className='flex items-center gap-2 mb-2.5'>
|
||||
<div className='w-7 h-7 rounded-lg bg-brand/10 dark:bg-brand-deep/30 flex items-center justify-center'>
|
||||
<CreditCard
|
||||
size={14}
|
||||
className='text-brand-deep dark:text-brand-from'
|
||||
/>
|
||||
</div>
|
||||
<h3 className='text-sm font-semibold text-gray-800 dark:text-gray-200'>
|
||||
{t('计费类型')}
|
||||
</h3>
|
||||
</div>
|
||||
<PricingQuotaTypes
|
||||
filterQuotaType={filterQuotaType}
|
||||
setFilterQuotaType={setFilterQuotaType}
|
||||
t={t}
|
||||
models={quotaTypeModels}
|
||||
title={null}
|
||||
/>
|
||||
</section>
|
||||
|
||||
{/* 标签 */}
|
||||
<section className='bg-white dark:bg-neutral-900 rounded-xl px-4 pt-3 pb-2 border border-gray-100 dark:border-neutral-800 shadow-sm [&>*:last-child]:!mb-0'>
|
||||
<div className='flex items-center gap-2 mb-2.5'>
|
||||
<div className='w-7 h-7 rounded-lg bg-brand/10 dark:bg-brand-deep/30 flex items-center justify-center'>
|
||||
<Tag
|
||||
size={14}
|
||||
className='text-brand-deep dark:text-brand-from'
|
||||
/>
|
||||
</div>
|
||||
<h3 className='text-sm font-semibold text-gray-800 dark:text-gray-200'>
|
||||
{t('标签')}
|
||||
</h3>
|
||||
</div>
|
||||
<PricingTags
|
||||
filterTag={filterTag}
|
||||
setFilterTag={setFilterTag}
|
||||
t={t}
|
||||
models={tagModels}
|
||||
allModels={allModels}
|
||||
title={null}
|
||||
/>
|
||||
</section>
|
||||
|
||||
{/* 端点类型 */}
|
||||
<section className='bg-white dark:bg-neutral-900 rounded-xl px-4 pt-3 pb-2 border border-gray-100 dark:border-neutral-800 shadow-sm [&>*:last-child]:!mb-0'>
|
||||
<div className='flex items-center gap-2 mb-2.5'>
|
||||
<div className='w-7 h-7 rounded-lg bg-brand/10 dark:bg-brand-deep/30 flex items-center justify-center'>
|
||||
<Layers
|
||||
size={14}
|
||||
className='text-brand-deep dark:text-brand-from'
|
||||
/>
|
||||
</div>
|
||||
<h3 className='text-sm font-semibold text-gray-800 dark:text-gray-200'>
|
||||
{t('端点类型')}
|
||||
</h3>
|
||||
</div>
|
||||
<PricingEndpointTypes
|
||||
filterEndpointType={filterEndpointType}
|
||||
setFilterEndpointType={setFilterEndpointType}
|
||||
endpointMap={endpointMap}
|
||||
t={t}
|
||||
models={endpointTypeModels}
|
||||
title={null}
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 底部操作区 */}
|
||||
<div className='p-4 bg-white dark:bg-neutral-900 border-t border-gray-200 dark:border-neutral-800'>
|
||||
<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-11 !font-medium !shadow-lg !shadow-brand/20 hover:!shadow-brand/30 transition-all'
|
||||
>
|
||||
{t('完成')}
|
||||
</Button>
|
||||
</div>
|
||||
</SideSheet>
|
||||
);
|
||||
};
|
||||
|
||||
export default FilterDrawer;
|
||||
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
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, { useState, useEffect, useRef } from 'react';
|
||||
import { useModelPricingData } from '../../../../hooks/model-pricing/useModelPricingData';
|
||||
import { usePricingFilterCounts } from '../../../../hooks/model-pricing/usePricingFilterCounts';
|
||||
import BentoHero from './BentoHero';
|
||||
import BentoGrid from './BentoGrid';
|
||||
import FilterBar from './FilterBar';
|
||||
import FilterDrawer from './FilterDrawer';
|
||||
import ModelDetailSideSheet from '../modal/ModelDetailSideSheet';
|
||||
import { ImagePreview } from '@douyinfe/semi-ui';
|
||||
import PageBackground from '../../../common/PageBackground';
|
||||
|
||||
const PricingBentoPage = () => {
|
||||
const pricingData = useModelPricingData();
|
||||
const [showSettings, setShowSettings] = useState(false);
|
||||
const pageRef = useRef(null);
|
||||
|
||||
// 为父级滚动容器 (.semi-layout) 添加自定义滚动条样式类
|
||||
// 进入页面时添加,离开时移除
|
||||
useEffect(() => {
|
||||
const el = pageRef.current;
|
||||
if (!el) return;
|
||||
|
||||
// 向上查找真正的滚动容器 (.semi-layout with overflow-y: auto)
|
||||
let scrollParent = el.parentElement;
|
||||
while (scrollParent) {
|
||||
const style = window.getComputedStyle(scrollParent);
|
||||
if (
|
||||
scrollParent.classList.contains('semi-layout') &&
|
||||
(style.overflowY === 'auto' || style.overflowY === 'scroll')
|
||||
) {
|
||||
break;
|
||||
}
|
||||
scrollParent = scrollParent.parentElement;
|
||||
}
|
||||
|
||||
if (scrollParent) {
|
||||
scrollParent.classList.add('pricing-page-scrollbar');
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (scrollParent) {
|
||||
scrollParent.classList.remove('pricing-page-scrollbar');
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Destructure what we need
|
||||
const {
|
||||
searchValue,
|
||||
setSearchValue,
|
||||
filterVendor,
|
||||
setFilterVendor,
|
||||
filteredModels,
|
||||
loading,
|
||||
selectedGroup,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
discountScope,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
currency,
|
||||
showRatio,
|
||||
hidePrice,
|
||||
t,
|
||||
copyText,
|
||||
openModelDetail,
|
||||
// Filter props for drawer
|
||||
filterTag,
|
||||
setFilterTag,
|
||||
filterQuotaType,
|
||||
setFilterQuotaType,
|
||||
filterEndpointType,
|
||||
setFilterEndpointType,
|
||||
filterGroup,
|
||||
setFilterGroup,
|
||||
autoGroups,
|
||||
endpointMap,
|
||||
vendorsMap,
|
||||
// Modal props
|
||||
showModelDetail,
|
||||
closeModelDetail,
|
||||
selectedModel,
|
||||
usableGroup,
|
||||
modalImageUrl,
|
||||
isModalOpenurl,
|
||||
setIsModalOpenurl,
|
||||
models, // Full list
|
||||
} = pricingData;
|
||||
|
||||
const { quotaTypeModels, endpointTypeModels, tagModels, groupCountModels } =
|
||||
usePricingFilterCounts({
|
||||
models: models,
|
||||
filterGroup,
|
||||
filterQuotaType,
|
||||
filterEndpointType,
|
||||
filterVendor,
|
||||
filterTag,
|
||||
searchValue,
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={pageRef}
|
||||
className='min-h-screen relative text-gray-900 dark:text-white selection:bg-brand/30 font-sans transition-colors duration-500'
|
||||
>
|
||||
{/* ===== BACKGROUND ===== */}
|
||||
{/* 统一页面背景层 —— 与全站其他页面(user-center / experience / key-management)
|
||||
* 同源,走 bg-glow-* 主题变量,跟随管理员「背景晕染起色/止色」配置。
|
||||
* 用 fixed 包一层让背景随滚动固定(定价页内容很长)。 */}
|
||||
<div className='fixed inset-0 -z-40 pointer-events-none'>
|
||||
<PageBackground variant='rich' />
|
||||
</div>
|
||||
|
||||
{/* ===== CONTENT ===== */}
|
||||
|
||||
{/* 1. Hero & Search */}
|
||||
<BentoHero
|
||||
searchValue={searchValue}
|
||||
setSearchValue={setSearchValue}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
{/* 2. Filter Bar (Sticky) */}
|
||||
<FilterBar
|
||||
vendorsMap={vendorsMap}
|
||||
filterVendor={filterVendor}
|
||||
setFilterVendor={setFilterVendor}
|
||||
filterGroup={filterGroup}
|
||||
setFilterGroup={setFilterGroup}
|
||||
groupCountModels={groupCountModels}
|
||||
groupRatio={groupRatio}
|
||||
autoGroups={autoGroups}
|
||||
showRatio={showRatio}
|
||||
onOpenDrawer={() => setShowSettings(true)}
|
||||
t={t}
|
||||
models={filteredModels}
|
||||
allModels={models}
|
||||
/>
|
||||
|
||||
{/* 企业作用域计价口径提示:标价含企业等级折扣,个人密钥/体验中心调用仍按个人等级计费 */}
|
||||
{discountScope === 'enterprise' && !hidePrice && (
|
||||
<div className='container mx-auto px-6 pt-3'>
|
||||
<div
|
||||
className='rounded-xl border border-amber-200/70 dark:border-amber-700/50
|
||||
bg-amber-50/80 dark:bg-amber-900/20 px-4 py-2 text-sm
|
||||
text-amber-800 dark:text-amber-300'
|
||||
>
|
||||
{t(
|
||||
'当前为企业作用域:以下价格已按企业等级折扣展示;使用个人密钥或体验中心调用时按个人等级计费。',
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 3. Main Content Grid */}
|
||||
<BentoGrid
|
||||
filteredModels={filteredModels}
|
||||
loading={loading}
|
||||
selectedGroup={selectedGroup}
|
||||
groupRatio={groupRatio}
|
||||
groupModelDiscount={groupModelDiscount}
|
||||
tokenUnit={tokenUnit}
|
||||
displayPrice={displayPrice}
|
||||
currency={currency}
|
||||
hidePrice={hidePrice}
|
||||
t={t}
|
||||
copyText={copyText}
|
||||
openModelDetail={openModelDetail}
|
||||
/>
|
||||
|
||||
{/* 4. Advanced Filters Drawer */}
|
||||
<FilterDrawer
|
||||
visible={showSettings}
|
||||
onClose={() => setShowSettings(false)}
|
||||
t={t}
|
||||
filterTag={filterTag}
|
||||
setFilterTag={setFilterTag}
|
||||
filterQuotaType={filterQuotaType}
|
||||
setFilterQuotaType={setFilterQuotaType}
|
||||
filterEndpointType={filterEndpointType}
|
||||
setFilterEndpointType={setFilterEndpointType}
|
||||
filterGroup={filterGroup}
|
||||
setFilterGroup={setFilterGroup}
|
||||
autoGroups={autoGroups}
|
||||
usableGroup={usableGroup}
|
||||
endpointMap={endpointMap}
|
||||
groupRatio={groupRatio}
|
||||
showRatio={showRatio}
|
||||
allModels={pricingData.models}
|
||||
tagModels={tagModels}
|
||||
quotaTypeModels={quotaTypeModels}
|
||||
endpointTypeModels={endpointTypeModels}
|
||||
groupCountModels={groupCountModels}
|
||||
/>
|
||||
|
||||
{/* 5. Legacy Modals (Detail View & Image Preview) */}
|
||||
<ModelDetailSideSheet
|
||||
visible={showModelDetail}
|
||||
onClose={closeModelDetail}
|
||||
modelData={selectedModel}
|
||||
groupRatio={groupRatio}
|
||||
groupModelDiscount={groupModelDiscount}
|
||||
usableGroup={usableGroup}
|
||||
currency={currency}
|
||||
tokenUnit={tokenUnit}
|
||||
displayPrice={displayPrice}
|
||||
showRatio={showRatio}
|
||||
hidePrice={hidePrice}
|
||||
vendorsMap={vendorsMap}
|
||||
endpointMap={endpointMap}
|
||||
autoGroups={autoGroups}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
<ImagePreview
|
||||
src={modalImageUrl}
|
||||
visible={isModalOpenurl}
|
||||
onVisibleChange={(visible) => setIsModalOpenurl(visible)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PricingBentoPage;
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
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 SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup';
|
||||
|
||||
const PricingDisplaySettings = ({
|
||||
showWithRecharge,
|
||||
setShowWithRecharge,
|
||||
currency,
|
||||
setCurrency,
|
||||
showRatio,
|
||||
viewMode,
|
||||
setViewMode,
|
||||
tokenUnit,
|
||||
setTokenUnit,
|
||||
loading = false,
|
||||
t,
|
||||
}) => {
|
||||
const items = [
|
||||
{
|
||||
value: 'recharge',
|
||||
label: t('充值价格显示'),
|
||||
},
|
||||
{
|
||||
value: 'tableView',
|
||||
label: t('表格视图'),
|
||||
},
|
||||
{
|
||||
value: 'tokenUnit',
|
||||
label: t('按K显示单位'),
|
||||
},
|
||||
];
|
||||
|
||||
const currencyItems = [
|
||||
{ value: 'USD', label: 'USD (¥)' },
|
||||
{ value: 'CNY', label: 'CNY (¥)' },
|
||||
{ value: 'CUSTOM', label: t('自定义货币') },
|
||||
];
|
||||
|
||||
const handleChange = (value) => {
|
||||
switch (value) {
|
||||
case 'recharge':
|
||||
setShowWithRecharge(!showWithRecharge);
|
||||
break;
|
||||
case 'tableView':
|
||||
setViewMode(viewMode === 'table' ? 'card' : 'table');
|
||||
break;
|
||||
case 'tokenUnit':
|
||||
setTokenUnit(tokenUnit === 'K' ? 'M' : 'K');
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
const getActiveValues = () => {
|
||||
const activeValues = [];
|
||||
if (showWithRecharge) activeValues.push('recharge');
|
||||
if (viewMode === 'table') activeValues.push('tableView');
|
||||
if (tokenUnit === 'K') activeValues.push('tokenUnit');
|
||||
return activeValues;
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<SelectableButtonGroup
|
||||
title={t('显示设置')}
|
||||
items={items}
|
||||
activeValue={getActiveValues()}
|
||||
onChange={handleChange}
|
||||
withCheckbox
|
||||
collapsible={false}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
{showWithRecharge && (
|
||||
<SelectableButtonGroup
|
||||
title={t('货币单位')}
|
||||
items={currencyItems}
|
||||
activeValue={currency}
|
||||
onChange={setCurrency}
|
||||
collapsible={false}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PricingDisplaySettings;
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
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 SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup';
|
||||
|
||||
/**
|
||||
* 端点类型筛选组件
|
||||
* @param {string|'all'} filterEndpointType 当前值
|
||||
* @param {Function} setFilterEndpointType setter
|
||||
* @param {Array} models 模型列表
|
||||
* @param {boolean} loading 是否加载中
|
||||
* @param {Function} t i18n
|
||||
*/
|
||||
const PricingEndpointTypes = ({
|
||||
filterEndpointType,
|
||||
setFilterEndpointType,
|
||||
models = [],
|
||||
allModels = [],
|
||||
loading = false,
|
||||
t,
|
||||
// 外层已有分区标题时传 null 隐藏内置标题(如 FilterDrawer),避免双标题
|
||||
title,
|
||||
}) => {
|
||||
// 获取系统中所有端点类型(基于 allModels,如果未提供则退化为 models)
|
||||
const getAllEndpointTypes = () => {
|
||||
const endpointTypes = new Set();
|
||||
(allModels.length > 0 ? allModels : models).forEach((model) => {
|
||||
if (
|
||||
model.supported_endpoint_types &&
|
||||
Array.isArray(model.supported_endpoint_types)
|
||||
) {
|
||||
model.supported_endpoint_types.forEach((endpoint) => {
|
||||
endpointTypes.add(endpoint);
|
||||
});
|
||||
}
|
||||
});
|
||||
return Array.from(endpointTypes).sort();
|
||||
};
|
||||
|
||||
// 计算每个端点类型的模型数量
|
||||
const getEndpointTypeCount = (endpointType) => {
|
||||
if (endpointType === 'all') {
|
||||
return models.length;
|
||||
}
|
||||
return models.filter(
|
||||
(model) =>
|
||||
model.supported_endpoint_types &&
|
||||
model.supported_endpoint_types.includes(endpointType),
|
||||
).length;
|
||||
};
|
||||
|
||||
// 端点类型显示名称映射
|
||||
const getEndpointTypeLabel = (endpointType) => {
|
||||
return endpointType;
|
||||
};
|
||||
|
||||
const availableEndpointTypes = getAllEndpointTypes();
|
||||
|
||||
const items = [
|
||||
{
|
||||
value: 'all',
|
||||
label: t('全部端点'),
|
||||
tagCount: getEndpointTypeCount('all'),
|
||||
disabled: models.length === 0,
|
||||
},
|
||||
...availableEndpointTypes.map((endpointType) => {
|
||||
const count = getEndpointTypeCount(endpointType);
|
||||
return {
|
||||
value: endpointType,
|
||||
label: getEndpointTypeLabel(endpointType),
|
||||
tagCount: count,
|
||||
disabled: count === 0,
|
||||
};
|
||||
}),
|
||||
];
|
||||
|
||||
return (
|
||||
<SelectableButtonGroup
|
||||
title={title === undefined ? t('端点类型') : title}
|
||||
items={items}
|
||||
activeValue={filterEndpointType}
|
||||
onChange={setFilterEndpointType}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default PricingEndpointTypes;
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
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 SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup';
|
||||
|
||||
/**
|
||||
* 分组筛选组件
|
||||
* @param {string} filterGroup 当前选中的分组,'all' 表示不过滤
|
||||
* @param {Function} setFilterGroup 设置选中分组
|
||||
* @param {Record<string, any>} usableGroup 后端返回的可用分组对象
|
||||
* @param {Record<string, number>} groupRatio 分组倍率对象
|
||||
* @param {Array} models 模型列表
|
||||
* @param {boolean} loading 是否加载中
|
||||
* @param {boolean} showRatio 是否显示倍率
|
||||
* @param {Function} t i18n
|
||||
*/
|
||||
const PricingGroups = ({
|
||||
filterGroup,
|
||||
setFilterGroup,
|
||||
usableGroup = {},
|
||||
groupRatio = {},
|
||||
models = [],
|
||||
loading = false,
|
||||
showRatio = true,
|
||||
t,
|
||||
// 外层已有分区标题时传 null 隐藏内置标题(如 FilterDrawer),避免双标题
|
||||
title,
|
||||
}) => {
|
||||
const groups = [
|
||||
'all',
|
||||
...Object.keys(usableGroup).filter((key) => key !== ''),
|
||||
];
|
||||
|
||||
const items = groups.map((g) => {
|
||||
const modelCount =
|
||||
g === 'all'
|
||||
? models.length
|
||||
: models.filter((m) => m.enable_groups && m.enable_groups.includes(g))
|
||||
.length;
|
||||
let ratioDisplay = '';
|
||||
if (g === 'all') {
|
||||
ratioDisplay = t('全部');
|
||||
} else if (showRatio) {
|
||||
// 只在 showRatio 为 true 时显示倍率
|
||||
const ratio = groupRatio[g];
|
||||
if (ratio !== undefined && ratio !== null) {
|
||||
ratioDisplay = `x${ratio}`;
|
||||
} else {
|
||||
ratioDisplay = 'x1';
|
||||
}
|
||||
} else {
|
||||
// showRatio 为 false 时显示模型数量
|
||||
ratioDisplay = `${modelCount}`;
|
||||
}
|
||||
return {
|
||||
value: g,
|
||||
label: g === 'all' ? t('全部分组') : g,
|
||||
tagCount: ratioDisplay,
|
||||
disabled: modelCount === 0,
|
||||
};
|
||||
});
|
||||
|
||||
return (
|
||||
<SelectableButtonGroup
|
||||
title={title === undefined ? t('可用令牌分组') : title}
|
||||
items={items}
|
||||
activeValue={filterGroup}
|
||||
onChange={setFilterGroup}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default PricingGroups;
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
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 SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup';
|
||||
|
||||
/**
|
||||
* 计费类型筛选组件
|
||||
* @param {string|'all'|0|1|2|3} filterQuotaType 当前值
|
||||
* @param {Function} setFilterQuotaType setter
|
||||
* @param {Array} models 模型列表
|
||||
* @param {boolean} loading 是否加载中
|
||||
* @param {Function} t i18n
|
||||
*/
|
||||
const PricingQuotaTypes = ({
|
||||
filterQuotaType,
|
||||
setFilterQuotaType,
|
||||
models = [],
|
||||
loading = false,
|
||||
t,
|
||||
// 外层已有分区标题时传 null 隐藏内置标题(如 FilterDrawer),避免双标题
|
||||
title,
|
||||
}) => {
|
||||
const qtyCount = (type) =>
|
||||
models.filter((m) => (type === 'all' ? true : m.quota_type === type))
|
||||
.length;
|
||||
|
||||
const items = [
|
||||
{ value: 'all', label: t('全部类型'), tagCount: qtyCount('all') },
|
||||
{ value: 0, label: t('按量计费'), tagCount: qtyCount(0) },
|
||||
{ value: 1, label: t('按次计费'), tagCount: qtyCount(1) },
|
||||
{ value: 2, label: t('按秒计费'), tagCount: qtyCount(2) },
|
||||
{ value: 3, label: t('按分辨率计费'), tagCount: qtyCount(3) },
|
||||
];
|
||||
|
||||
return (
|
||||
<SelectableButtonGroup
|
||||
title={title === undefined ? t('计费类型') : title}
|
||||
items={items}
|
||||
activeValue={filterQuotaType}
|
||||
onChange={setFilterQuotaType}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default PricingQuotaTypes;
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
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 SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup';
|
||||
|
||||
/**
|
||||
* 模型标签筛选组件
|
||||
* @param {string|'all'} filterTag 当前选中的标签
|
||||
* @param {Function} setFilterTag setter
|
||||
* @param {Array} models 当前过滤后模型列表(用于计数)
|
||||
* @param {Array} allModels 所有模型列表(用于获取所有标签)
|
||||
* @param {boolean} loading 是否加载中
|
||||
* @param {Function} t i18n
|
||||
*/
|
||||
const PricingTags = ({
|
||||
filterTag,
|
||||
setFilterTag,
|
||||
models = [],
|
||||
allModels = [],
|
||||
loading = false,
|
||||
t,
|
||||
// 外层已有分区标题时传 null 隐藏内置标题(如 FilterDrawer),避免双标题
|
||||
title,
|
||||
}) => {
|
||||
// 提取系统所有标签
|
||||
const getAllTags = React.useMemo(() => {
|
||||
const tagSet = new Set();
|
||||
|
||||
(allModels.length > 0 ? allModels : models).forEach((model) => {
|
||||
if (model.tags) {
|
||||
model.tags
|
||||
.split(/[,;|]+/) // 逗号、分号或竖线(保留空格,允许多词标签如 "open weights")
|
||||
.map((tag) => tag.trim())
|
||||
.filter(Boolean)
|
||||
.forEach((tag) => tagSet.add(tag.toLowerCase()));
|
||||
}
|
||||
});
|
||||
|
||||
return Array.from(tagSet).sort((a, b) => a.localeCompare(b));
|
||||
}, [allModels, models]);
|
||||
|
||||
// 计算标签对应的模型数量
|
||||
const getTagCount = React.useCallback(
|
||||
(tag) => {
|
||||
if (tag === 'all') return models.length;
|
||||
|
||||
const tagLower = tag.toLowerCase();
|
||||
return models.filter((model) => {
|
||||
if (!model.tags) return false;
|
||||
return model.tags
|
||||
.toLowerCase()
|
||||
.split(/[,;|]+/)
|
||||
.map((tg) => tg.trim())
|
||||
.includes(tagLower);
|
||||
}).length;
|
||||
},
|
||||
[models],
|
||||
);
|
||||
|
||||
const items = React.useMemo(() => {
|
||||
const result = [
|
||||
{
|
||||
value: 'all',
|
||||
label: t('全部标签'),
|
||||
tagCount: getTagCount('all'),
|
||||
disabled: models.length === 0,
|
||||
},
|
||||
];
|
||||
|
||||
getAllTags.forEach((tag) => {
|
||||
const count = getTagCount(tag);
|
||||
result.push({
|
||||
value: tag,
|
||||
label: tag,
|
||||
tagCount: count,
|
||||
disabled: count === 0,
|
||||
});
|
||||
});
|
||||
|
||||
return result;
|
||||
}, [getAllTags, getTagCount, t, models.length]);
|
||||
|
||||
return (
|
||||
<SelectableButtonGroup
|
||||
title={title === undefined ? t('标签') : title}
|
||||
items={items}
|
||||
activeValue={filterTag}
|
||||
onChange={setFilterTag}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default PricingTags;
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
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 SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup';
|
||||
import { getLobeHubIcon } from '../../../../helpers';
|
||||
|
||||
/**
|
||||
* 供应商筛选组件
|
||||
* @param {string|'all'} filterVendor 当前值
|
||||
* @param {Function} setFilterVendor setter
|
||||
* @param {Array} models 模型列表
|
||||
* @param {Array} allModels 所有模型列表(用于获取全部供应商)
|
||||
* @param {boolean} loading 是否加载中
|
||||
* @param {Function} t i18n
|
||||
*/
|
||||
const PricingVendors = ({
|
||||
filterVendor,
|
||||
setFilterVendor,
|
||||
models = [],
|
||||
allModels = [],
|
||||
loading = false,
|
||||
t,
|
||||
}) => {
|
||||
// 获取系统中所有供应商(基于 allModels,如果未提供则退化为 models)
|
||||
const getAllVendors = React.useMemo(() => {
|
||||
const vendors = new Set();
|
||||
const vendorIcons = new Map();
|
||||
let hasUnknownVendor = false;
|
||||
|
||||
(allModels.length > 0 ? allModels : models).forEach((model) => {
|
||||
if (model.vendor_name) {
|
||||
vendors.add(model.vendor_name);
|
||||
if (model.vendor_icon && !vendorIcons.has(model.vendor_name)) {
|
||||
vendorIcons.set(model.vendor_name, model.vendor_icon);
|
||||
}
|
||||
} else {
|
||||
hasUnknownVendor = true;
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
vendors: Array.from(vendors).sort(),
|
||||
vendorIcons,
|
||||
hasUnknownVendor,
|
||||
};
|
||||
}, [allModels, models]);
|
||||
|
||||
// 计算每个供应商的模型数量(基于当前过滤后的 models)
|
||||
const getVendorCount = React.useCallback(
|
||||
(vendor) => {
|
||||
if (vendor === 'all') {
|
||||
return models.length;
|
||||
}
|
||||
if (vendor === 'unknown') {
|
||||
return models.filter((model) => !model.vendor_name).length;
|
||||
}
|
||||
return models.filter((model) => model.vendor_name === vendor).length;
|
||||
},
|
||||
[models],
|
||||
);
|
||||
|
||||
// 生成供应商选项
|
||||
const items = React.useMemo(() => {
|
||||
const result = [
|
||||
{
|
||||
value: 'all',
|
||||
label: t('全部供应商'),
|
||||
tagCount: getVendorCount('all'),
|
||||
disabled: models.length === 0,
|
||||
},
|
||||
];
|
||||
|
||||
// 添加所有已知供应商
|
||||
getAllVendors.vendors.forEach((vendor) => {
|
||||
const count = getVendorCount(vendor);
|
||||
const icon = getAllVendors.vendorIcons.get(vendor);
|
||||
result.push({
|
||||
value: vendor,
|
||||
label: vendor,
|
||||
icon: icon ? getLobeHubIcon(icon, 16) : null,
|
||||
tagCount: count,
|
||||
disabled: count === 0,
|
||||
});
|
||||
});
|
||||
|
||||
// 如果系统中存在未知供应商,添加"未知供应商"选项
|
||||
if (getAllVendors.hasUnknownVendor) {
|
||||
const count = getVendorCount('unknown');
|
||||
result.push({
|
||||
value: 'unknown',
|
||||
label: t('未知供应商'),
|
||||
tagCount: count,
|
||||
disabled: count === 0,
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}, [getAllVendors, getVendorCount, t]);
|
||||
|
||||
return (
|
||||
<SelectableButtonGroup
|
||||
title={t('供应商')}
|
||||
items={items}
|
||||
activeValue={filterVendor}
|
||||
onChange={setFilterVendor}
|
||||
loading={loading}
|
||||
t={t}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default PricingVendors;
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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 PricingBentoPage from '../bento/PricingBentoPage';
|
||||
|
||||
const PricingPage = () => {
|
||||
return <PricingBentoPage />;
|
||||
};
|
||||
|
||||
export default PricingPage;
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
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';
|
||||
import PricingGroups from '../filter/PricingGroups';
|
||||
import PricingQuotaTypes from '../filter/PricingQuotaTypes';
|
||||
import PricingVendors from '../filter/PricingVendors';
|
||||
import PricingTags from '../filter/PricingTags';
|
||||
|
||||
import { resetPricingFilters } from '../../../../helpers/utils';
|
||||
import { usePricingFilterCounts } from '../../../../hooks/model-pricing/usePricingFilterCounts';
|
||||
|
||||
const PricingSidebar = ({
|
||||
showWithRecharge,
|
||||
setShowWithRecharge,
|
||||
currency,
|
||||
setCurrency,
|
||||
handleChange,
|
||||
setActiveKey,
|
||||
showRatio,
|
||||
viewMode,
|
||||
setViewMode,
|
||||
filterGroup,
|
||||
setFilterGroup,
|
||||
handleGroupClick,
|
||||
filterQuotaType,
|
||||
setFilterQuotaType,
|
||||
filterEndpointType,
|
||||
setFilterEndpointType,
|
||||
filterVendor,
|
||||
setFilterVendor,
|
||||
filterTag,
|
||||
setFilterTag,
|
||||
currentPage,
|
||||
setCurrentPage,
|
||||
tokenUnit,
|
||||
setTokenUnit,
|
||||
loading,
|
||||
t,
|
||||
...categoryProps
|
||||
}) => {
|
||||
const {
|
||||
quotaTypeModels,
|
||||
vendorModels,
|
||||
tagModels,
|
||||
groupCountModels,
|
||||
} = usePricingFilterCounts({
|
||||
models: categoryProps.models,
|
||||
filterGroup,
|
||||
filterQuotaType,
|
||||
filterEndpointType,
|
||||
filterVendor,
|
||||
filterTag,
|
||||
searchValue: categoryProps.searchValue,
|
||||
});
|
||||
|
||||
const handleResetFilters = () =>
|
||||
resetPricingFilters({
|
||||
handleChange,
|
||||
setShowWithRecharge,
|
||||
setCurrency,
|
||||
setViewMode,
|
||||
setFilterGroup,
|
||||
setFilterQuotaType,
|
||||
setFilterEndpointType,
|
||||
setFilterVendor,
|
||||
setFilterTag,
|
||||
setCurrentPage,
|
||||
setTokenUnit,
|
||||
});
|
||||
|
||||
return (
|
||||
<div className='p-2'>
|
||||
<div className='flex items-center justify-between mb-6'>
|
||||
<div className='text-lg font-semibold text-gray-800'>{t('筛选')}</div>
|
||||
<Button
|
||||
theme='outline'
|
||||
type='tertiary'
|
||||
onClick={handleResetFilters}
|
||||
className='text-gray-500 hover:text-gray-700'
|
||||
>
|
||||
{t('重置')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<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={handleGroupClick}
|
||||
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}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PricingSidebar;
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
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 PricingTopSection from '../header/PricingTopSection';
|
||||
import PricingView from './PricingView';
|
||||
|
||||
const PricingContent = ({ isMobile, sidebarProps, ...props }) => {
|
||||
return (
|
||||
<div
|
||||
className={isMobile ? 'pricing-content-mobile' : 'pricing-scroll-hide'}
|
||||
>
|
||||
{/* 固定的顶部区域(分类介绍 + 搜索和操作) */}
|
||||
<div className='pricing-search-header'>
|
||||
<PricingTopSection
|
||||
{...props}
|
||||
isMobile={isMobile}
|
||||
sidebarProps={sidebarProps}
|
||||
showWithRecharge={sidebarProps.showWithRecharge}
|
||||
setShowWithRecharge={sidebarProps.setShowWithRecharge}
|
||||
currency={sidebarProps.currency}
|
||||
setCurrency={sidebarProps.setCurrency}
|
||||
showRatio={sidebarProps.showRatio}
|
||||
viewMode={sidebarProps.viewMode}
|
||||
setViewMode={sidebarProps.setViewMode}
|
||||
tokenUnit={sidebarProps.tokenUnit}
|
||||
setTokenUnit={sidebarProps.setTokenUnit}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 可滚动的内容区域 */}
|
||||
<div
|
||||
className={
|
||||
isMobile ? 'pricing-view-container-mobile' : 'pricing-view-container'
|
||||
}
|
||||
>
|
||||
<PricingView {...props} viewMode={sidebarProps.viewMode} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PricingContent;
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
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 PricingTable from '../../view/table/PricingTable';
|
||||
import PricingCardView from '../../view/card/PricingCardView';
|
||||
|
||||
const PricingView = ({ viewMode = 'table', ...props }) => {
|
||||
return viewMode === 'card' ? (
|
||||
<PricingCardView {...props} />
|
||||
) : (
|
||||
<PricingTable {...props} />
|
||||
);
|
||||
};
|
||||
|
||||
export default PricingView;
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
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, { useState, memo } from 'react';
|
||||
import PricingFilterModal from '../../modal/PricingFilterModal';
|
||||
import PricingVendorIntroWithSkeleton from './PricingVendorIntroWithSkeleton';
|
||||
import SearchActions from './SearchActions';
|
||||
|
||||
const PricingTopSection = memo(
|
||||
({
|
||||
selectedRowKeys,
|
||||
copyText,
|
||||
handleChange,
|
||||
handleCompositionStart,
|
||||
handleCompositionEnd,
|
||||
isMobile,
|
||||
sidebarProps,
|
||||
filterVendor,
|
||||
models,
|
||||
filteredModels,
|
||||
loading,
|
||||
searchValue,
|
||||
showWithRecharge,
|
||||
setShowWithRecharge,
|
||||
currency,
|
||||
setCurrency,
|
||||
viewMode,
|
||||
setViewMode,
|
||||
tokenUnit,
|
||||
setTokenUnit,
|
||||
t,
|
||||
}) => {
|
||||
const [showFilterModal, setShowFilterModal] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
{isMobile ? (
|
||||
<>
|
||||
<div className='w-full'>
|
||||
<SearchActions
|
||||
selectedRowKeys={selectedRowKeys}
|
||||
copyText={copyText}
|
||||
handleChange={handleChange}
|
||||
handleCompositionStart={handleCompositionStart}
|
||||
handleCompositionEnd={handleCompositionEnd}
|
||||
isMobile={isMobile}
|
||||
searchValue={searchValue}
|
||||
setShowFilterModal={setShowFilterModal}
|
||||
showWithRecharge={showWithRecharge}
|
||||
setShowWithRecharge={setShowWithRecharge}
|
||||
currency={currency}
|
||||
setCurrency={setCurrency}
|
||||
viewMode={viewMode}
|
||||
setViewMode={setViewMode}
|
||||
tokenUnit={tokenUnit}
|
||||
setTokenUnit={setTokenUnit}
|
||||
t={t}
|
||||
/>
|
||||
</div>
|
||||
<PricingFilterModal
|
||||
visible={showFilterModal}
|
||||
onClose={() => setShowFilterModal(false)}
|
||||
sidebarProps={sidebarProps}
|
||||
t={t}
|
||||
/>
|
||||
</>
|
||||
) : (
|
||||
<PricingVendorIntroWithSkeleton
|
||||
loading={loading}
|
||||
filterVendor={filterVendor}
|
||||
models={filteredModels}
|
||||
allModels={models}
|
||||
t={t}
|
||||
selectedRowKeys={selectedRowKeys}
|
||||
copyText={copyText}
|
||||
handleChange={handleChange}
|
||||
handleCompositionStart={handleCompositionStart}
|
||||
handleCompositionEnd={handleCompositionEnd}
|
||||
isMobile={isMobile}
|
||||
searchValue={searchValue}
|
||||
setShowFilterModal={setShowFilterModal}
|
||||
showWithRecharge={showWithRecharge}
|
||||
setShowWithRecharge={setShowWithRecharge}
|
||||
currency={currency}
|
||||
setCurrency={setCurrency}
|
||||
viewMode={viewMode}
|
||||
setViewMode={setViewMode}
|
||||
tokenUnit={tokenUnit}
|
||||
setTokenUnit={setTokenUnit}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
PricingTopSection.displayName = 'PricingTopSection';
|
||||
|
||||
export default PricingTopSection;
|
||||
@@ -0,0 +1,413 @@
|
||||
/*
|
||||
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, { useState, useEffect, useMemo, useCallback, memo } from 'react';
|
||||
import {
|
||||
Card,
|
||||
Tag,
|
||||
Avatar,
|
||||
Typography,
|
||||
Tooltip,
|
||||
Modal,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { getLobeHubIcon } from '../../../../../helpers';
|
||||
import SearchActions from './SearchActions';
|
||||
|
||||
const { Paragraph } = Typography;
|
||||
|
||||
const CONFIG = {
|
||||
CAROUSEL_INTERVAL: 2000,
|
||||
ICON_SIZE: 40,
|
||||
UNKNOWN_VENDOR: 'unknown',
|
||||
};
|
||||
|
||||
const THEME_COLORS = {
|
||||
allVendors: {
|
||||
primary: '37 99 235',
|
||||
background: 'rgba(59, 130, 246, 0.08)',
|
||||
},
|
||||
specific: {
|
||||
primary: '16 185 129',
|
||||
background: 'rgba(16, 185, 129, 0.1)',
|
||||
},
|
||||
};
|
||||
|
||||
const COMPONENT_STYLES = {
|
||||
tag: {
|
||||
backgroundColor: 'rgba(255,255,255,0.95)',
|
||||
color: '#1f2937',
|
||||
border: '1px solid rgba(255,255,255,0.8)',
|
||||
fontWeight: '500',
|
||||
},
|
||||
avatarContainer:
|
||||
'w-16 h-16 rounded-2xl bg-white/90 shadow-md backdrop-blur-sm flex items-center justify-center',
|
||||
titleText: { color: 'white' },
|
||||
descriptionText: { color: 'rgba(255,255,255,0.9)' },
|
||||
};
|
||||
|
||||
const CONTENT_TEXTS = {
|
||||
unknown: {
|
||||
displayName: (t) => t('未知供应商'),
|
||||
description: (t) =>
|
||||
t(
|
||||
'包含来自未知或未标明供应商的AI模型,这些模型可能来自小型供应商或开源项目。',
|
||||
),
|
||||
},
|
||||
all: {
|
||||
description: (t) =>
|
||||
t('查看所有可用的AI模型供应商,包括众多知名供应商的模型。'),
|
||||
},
|
||||
fallback: {
|
||||
description: (t) => t('该供应商提供多种AI模型,适用于不同的应用场景。'),
|
||||
},
|
||||
};
|
||||
|
||||
const getVendorDisplayName = (vendorName, t) => {
|
||||
return vendorName === CONFIG.UNKNOWN_VENDOR
|
||||
? CONTENT_TEXTS.unknown.displayName(t)
|
||||
: vendorName;
|
||||
};
|
||||
|
||||
const createDefaultAvatar = () => (
|
||||
<div className={COMPONENT_STYLES.avatarContainer}>
|
||||
<Avatar size='large' color='transparent'>
|
||||
AI
|
||||
</Avatar>
|
||||
</div>
|
||||
);
|
||||
|
||||
const getAvatarBackgroundColor = (isAllVendors) =>
|
||||
isAllVendors
|
||||
? THEME_COLORS.allVendors.background
|
||||
: THEME_COLORS.specific.background;
|
||||
|
||||
const getAvatarText = (vendorName) =>
|
||||
vendorName === CONFIG.UNKNOWN_VENDOR
|
||||
? '?'
|
||||
: vendorName.charAt(0).toUpperCase();
|
||||
|
||||
const createAvatarContent = (vendor, isAllVendors) => {
|
||||
if (vendor.icon) {
|
||||
return getLobeHubIcon(vendor.icon, CONFIG.ICON_SIZE);
|
||||
}
|
||||
|
||||
return (
|
||||
<Avatar
|
||||
size='large'
|
||||
style={{ backgroundColor: getAvatarBackgroundColor(isAllVendors) }}
|
||||
>
|
||||
{getAvatarText(vendor.name)}
|
||||
</Avatar>
|
||||
);
|
||||
};
|
||||
|
||||
const renderVendorAvatar = (vendor, t, isAllVendors = false) => {
|
||||
if (!vendor) {
|
||||
return createDefaultAvatar();
|
||||
}
|
||||
|
||||
const displayName = getVendorDisplayName(vendor.name, t);
|
||||
const avatarContent = createAvatarContent(vendor, isAllVendors);
|
||||
|
||||
return (
|
||||
<Tooltip content={displayName} position='top'>
|
||||
<div className={COMPONENT_STYLES.avatarContainer}>{avatarContent}</div>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
const PricingVendorIntro = memo(
|
||||
({
|
||||
filterVendor,
|
||||
models = [],
|
||||
allModels = [],
|
||||
t,
|
||||
selectedRowKeys = [],
|
||||
copyText,
|
||||
handleChange,
|
||||
handleCompositionStart,
|
||||
handleCompositionEnd,
|
||||
isMobile = false,
|
||||
searchValue = '',
|
||||
setShowFilterModal,
|
||||
showWithRecharge,
|
||||
setShowWithRecharge,
|
||||
currency,
|
||||
setCurrency,
|
||||
viewMode,
|
||||
setViewMode,
|
||||
tokenUnit,
|
||||
setTokenUnit,
|
||||
}) => {
|
||||
const [currentOffset, setCurrentOffset] = useState(0);
|
||||
const [descModalVisible, setDescModalVisible] = useState(false);
|
||||
const [descModalContent, setDescModalContent] = useState('');
|
||||
|
||||
const handleOpenDescModal = useCallback((content) => {
|
||||
setDescModalContent(content || '');
|
||||
setDescModalVisible(true);
|
||||
}, []);
|
||||
|
||||
const handleCloseDescModal = useCallback(() => {
|
||||
setDescModalVisible(false);
|
||||
}, []);
|
||||
|
||||
const renderDescriptionModal = useCallback(
|
||||
() => (
|
||||
<Modal
|
||||
title={t('供应商介绍')}
|
||||
visible={descModalVisible}
|
||||
onCancel={handleCloseDescModal}
|
||||
footer={null}
|
||||
width={isMobile ? '95%' : 600}
|
||||
bodyStyle={{
|
||||
maxHeight: isMobile ? '70vh' : '60vh',
|
||||
overflowY: 'auto',
|
||||
}}
|
||||
>
|
||||
<div className='text-sm mb-4'>{descModalContent}</div>
|
||||
</Modal>
|
||||
),
|
||||
[descModalVisible, descModalContent, handleCloseDescModal, isMobile, t],
|
||||
);
|
||||
|
||||
const vendorInfo = useMemo(() => {
|
||||
const vendors = new Map();
|
||||
let unknownCount = 0;
|
||||
|
||||
const sourceModels =
|
||||
Array.isArray(allModels) && allModels.length > 0 ? allModels : models;
|
||||
|
||||
sourceModels.forEach((model) => {
|
||||
if (model.vendor_name) {
|
||||
const existing = vendors.get(model.vendor_name);
|
||||
if (existing) {
|
||||
existing.count++;
|
||||
} else {
|
||||
vendors.set(model.vendor_name, {
|
||||
name: model.vendor_name,
|
||||
icon: model.vendor_icon,
|
||||
description: model.vendor_description,
|
||||
count: 1,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
unknownCount++;
|
||||
}
|
||||
});
|
||||
|
||||
const vendorList = Array.from(vendors.values()).sort((a, b) =>
|
||||
a.name.localeCompare(b.name),
|
||||
);
|
||||
|
||||
if (unknownCount > 0) {
|
||||
vendorList.push({
|
||||
name: CONFIG.UNKNOWN_VENDOR,
|
||||
icon: null,
|
||||
description: CONTENT_TEXTS.unknown.description(t),
|
||||
count: unknownCount,
|
||||
});
|
||||
}
|
||||
|
||||
return vendorList;
|
||||
}, [allModels, models, t]);
|
||||
|
||||
const currentModelCount = models.length;
|
||||
|
||||
useEffect(() => {
|
||||
if (filterVendor !== 'all' || vendorInfo.length <= 1) {
|
||||
setCurrentOffset(0);
|
||||
return;
|
||||
}
|
||||
|
||||
const interval = setInterval(() => {
|
||||
setCurrentOffset((prev) => (prev + 1) % vendorInfo.length);
|
||||
}, CONFIG.CAROUSEL_INTERVAL);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
}, [filterVendor, vendorInfo.length]);
|
||||
|
||||
const getVendorDescription = useCallback(
|
||||
(vendorKey) => {
|
||||
if (vendorKey === 'all') {
|
||||
return CONTENT_TEXTS.all.description(t);
|
||||
}
|
||||
if (vendorKey === CONFIG.UNKNOWN_VENDOR) {
|
||||
return CONTENT_TEXTS.unknown.description(t);
|
||||
}
|
||||
const vendor = vendorInfo.find((v) => v.name === vendorKey);
|
||||
return vendor?.description || CONTENT_TEXTS.fallback.description(t);
|
||||
},
|
||||
[vendorInfo, t],
|
||||
);
|
||||
|
||||
const createCoverStyle = useCallback(
|
||||
(primaryColor) => ({
|
||||
'--palette-primary-darkerChannel': primaryColor,
|
||||
backgroundImage: `linear-gradient(0deg, rgba(var(--palette-primary-darkerChannel) / 80%), rgba(var(--palette-primary-darkerChannel) / 80%)), url('/cover-4.webp')`,
|
||||
backgroundSize: 'cover',
|
||||
backgroundPosition: 'center',
|
||||
backgroundRepeat: 'no-repeat',
|
||||
}),
|
||||
[],
|
||||
);
|
||||
|
||||
const renderSearchActions = useCallback(
|
||||
() => (
|
||||
<SearchActions
|
||||
selectedRowKeys={selectedRowKeys}
|
||||
copyText={copyText}
|
||||
handleChange={handleChange}
|
||||
handleCompositionStart={handleCompositionStart}
|
||||
handleCompositionEnd={handleCompositionEnd}
|
||||
isMobile={isMobile}
|
||||
searchValue={searchValue}
|
||||
setShowFilterModal={setShowFilterModal}
|
||||
showWithRecharge={showWithRecharge}
|
||||
setShowWithRecharge={setShowWithRecharge}
|
||||
currency={currency}
|
||||
setCurrency={setCurrency}
|
||||
viewMode={viewMode}
|
||||
setViewMode={setViewMode}
|
||||
tokenUnit={tokenUnit}
|
||||
setTokenUnit={setTokenUnit}
|
||||
t={t}
|
||||
/>
|
||||
),
|
||||
[
|
||||
selectedRowKeys,
|
||||
copyText,
|
||||
handleChange,
|
||||
handleCompositionStart,
|
||||
handleCompositionEnd,
|
||||
isMobile,
|
||||
searchValue,
|
||||
setShowFilterModal,
|
||||
showWithRecharge,
|
||||
setShowWithRecharge,
|
||||
currency,
|
||||
setCurrency,
|
||||
viewMode,
|
||||
setViewMode,
|
||||
tokenUnit,
|
||||
setTokenUnit,
|
||||
t,
|
||||
],
|
||||
);
|
||||
|
||||
const renderHeaderCard = useCallback(
|
||||
({ title, count, description, rightContent, primaryDarkerChannel }) => (
|
||||
<Card
|
||||
className='!rounded-2xl shadow-sm border-0'
|
||||
cover={
|
||||
<div
|
||||
className='relative h-full'
|
||||
style={createCoverStyle(primaryDarkerChannel)}
|
||||
>
|
||||
<div className='relative z-10 h-full flex items-center justify-between p-4'>
|
||||
<div className='flex-1 min-w-0 mr-4'>
|
||||
<div className='flex flex-row flex-wrap items-center gap-2 sm:gap-3 mb-2'>
|
||||
<h2
|
||||
className='text-lg sm:text-xl font-bold truncate'
|
||||
style={COMPONENT_STYLES.titleText}
|
||||
>
|
||||
{title}
|
||||
</h2>
|
||||
<Tag
|
||||
style={COMPONENT_STYLES.tag}
|
||||
shape='circle'
|
||||
size='small'
|
||||
className='self-center'
|
||||
>
|
||||
{t('共 {{count}} 个模型', { count })}
|
||||
</Tag>
|
||||
</div>
|
||||
<Paragraph
|
||||
className='text-xs sm:text-sm leading-relaxed !mb-0 cursor-pointer'
|
||||
style={COMPONENT_STYLES.descriptionText}
|
||||
ellipsis={{ rows: 2 }}
|
||||
onClick={() => handleOpenDescModal(description)}
|
||||
>
|
||||
{description}
|
||||
</Paragraph>
|
||||
</div>
|
||||
|
||||
<div className='flex-shrink-0'>{rightContent}</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
{renderSearchActions()}
|
||||
</Card>
|
||||
),
|
||||
[renderSearchActions, createCoverStyle, handleOpenDescModal, t],
|
||||
);
|
||||
|
||||
const renderAllVendorsAvatar = useCallback(() => {
|
||||
const currentVendor =
|
||||
vendorInfo.length > 0
|
||||
? vendorInfo[currentOffset % vendorInfo.length]
|
||||
: null;
|
||||
return renderVendorAvatar(currentVendor, t, true);
|
||||
}, [vendorInfo, currentOffset, t]);
|
||||
|
||||
if (filterVendor === 'all') {
|
||||
const headerCard = renderHeaderCard({
|
||||
title: t('全部供应商'),
|
||||
count: currentModelCount,
|
||||
description: getVendorDescription('all'),
|
||||
rightContent: renderAllVendorsAvatar(),
|
||||
primaryDarkerChannel: THEME_COLORS.allVendors.primary,
|
||||
});
|
||||
return (
|
||||
<>
|
||||
{headerCard}
|
||||
{renderDescriptionModal()}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const currentVendor = vendorInfo.find((v) => v.name === filterVendor);
|
||||
if (!currentVendor) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const vendorDisplayName = getVendorDisplayName(currentVendor.name, t);
|
||||
|
||||
const headerCard = renderHeaderCard({
|
||||
title: vendorDisplayName,
|
||||
count: currentModelCount,
|
||||
description:
|
||||
currentVendor.description || getVendorDescription(currentVendor.name),
|
||||
rightContent: renderVendorAvatar(currentVendor, t, false),
|
||||
primaryDarkerChannel: THEME_COLORS.specific.primary,
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
{headerCard}
|
||||
{renderDescriptionModal()}
|
||||
</>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
PricingVendorIntro.displayName = 'PricingVendorIntro';
|
||||
|
||||
export default PricingVendorIntro;
|
||||
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
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, { memo } from 'react';
|
||||
import { Card, Skeleton } from '@douyinfe/semi-ui';
|
||||
|
||||
const THEME_COLORS = {
|
||||
allVendors: {
|
||||
primary: '37 99 235',
|
||||
background: 'rgba(59, 130, 246, 0.1)',
|
||||
border: 'rgba(59, 130, 246, 0.2)',
|
||||
},
|
||||
specific: {
|
||||
primary: '16 185 129',
|
||||
background: 'rgba(16, 185, 129, 0.1)',
|
||||
border: 'rgba(16, 185, 129, 0.2)',
|
||||
},
|
||||
neutral: {
|
||||
background: 'rgba(156, 163, 175, 0.1)',
|
||||
border: 'rgba(156, 163, 175, 0.2)',
|
||||
},
|
||||
};
|
||||
|
||||
const SIZES = {
|
||||
title: { width: { all: 120, specific: 100 }, height: 24 },
|
||||
tag: { width: 80, height: 20 },
|
||||
description: { height: 14 },
|
||||
avatar: { width: 40, height: 40 },
|
||||
searchInput: { height: 32 },
|
||||
button: { width: 80, height: 32 },
|
||||
};
|
||||
|
||||
const SKELETON_STYLES = {
|
||||
cover: (primaryColor) => ({
|
||||
'--palette-primary-darkerChannel': primaryColor,
|
||||
backgroundImage: `linear-gradient(0deg, rgba(var(--palette-primary-darkerChannel) / 80%), rgba(var(--palette-primary-darkerChannel) / 80%)), url('/cover-4.webp')`,
|
||||
backgroundSize: 'cover',
|
||||
backgroundPosition: 'center',
|
||||
backgroundRepeat: 'no-repeat',
|
||||
}),
|
||||
title: {
|
||||
backgroundColor: 'rgba(255, 255, 255, 0.25)',
|
||||
borderRadius: 8,
|
||||
backdropFilter: 'blur(4px)',
|
||||
},
|
||||
tag: {
|
||||
backgroundColor: 'rgba(255, 255, 255, 0.2)',
|
||||
borderRadius: 9999,
|
||||
backdropFilter: 'blur(4px)',
|
||||
border: '1px solid rgba(255,255,255,0.3)',
|
||||
},
|
||||
description: {
|
||||
backgroundColor: 'rgba(255, 255, 255, 0.2)',
|
||||
borderRadius: 4,
|
||||
backdropFilter: 'blur(4px)',
|
||||
},
|
||||
avatar: (isAllVendors) => {
|
||||
const colors = isAllVendors
|
||||
? THEME_COLORS.allVendors
|
||||
: THEME_COLORS.specific;
|
||||
return {
|
||||
backgroundColor: colors.background,
|
||||
borderRadius: 12,
|
||||
border: `1px solid ${colors.border}`,
|
||||
};
|
||||
},
|
||||
searchInput: {
|
||||
backgroundColor: THEME_COLORS.neutral.background,
|
||||
borderRadius: 8,
|
||||
border: `1px solid ${THEME_COLORS.neutral.border}`,
|
||||
},
|
||||
button: {
|
||||
backgroundColor: THEME_COLORS.neutral.background,
|
||||
borderRadius: 8,
|
||||
border: `1px solid ${THEME_COLORS.neutral.border}`,
|
||||
},
|
||||
};
|
||||
|
||||
const createSkeletonRect = (style = {}, key = null) => (
|
||||
<div key={key} className='animate-pulse' style={style} />
|
||||
);
|
||||
|
||||
const PricingVendorIntroSkeleton = memo(
|
||||
({ isAllVendors = false, isMobile = false }) => {
|
||||
const placeholder = (
|
||||
<Card
|
||||
className='!rounded-2xl shadow-sm border-0'
|
||||
cover={
|
||||
<div
|
||||
className='relative h-full'
|
||||
style={SKELETON_STYLES.cover(
|
||||
isAllVendors
|
||||
? THEME_COLORS.allVendors.primary
|
||||
: THEME_COLORS.specific.primary,
|
||||
)}
|
||||
>
|
||||
<div className='relative z-10 h-full flex items-center justify-between p-4'>
|
||||
<div className='flex-1 min-w-0 mr-4'>
|
||||
<div className='flex flex-row flex-wrap items-center gap-2 sm:gap-3 mb-2'>
|
||||
{createSkeletonRect(
|
||||
{
|
||||
...SKELETON_STYLES.title,
|
||||
width: isAllVendors
|
||||
? SIZES.title.width.all
|
||||
: SIZES.title.width.specific,
|
||||
height: SIZES.title.height,
|
||||
},
|
||||
'title',
|
||||
)}
|
||||
{createSkeletonRect(
|
||||
{
|
||||
...SKELETON_STYLES.tag,
|
||||
width: SIZES.tag.width,
|
||||
height: SIZES.tag.height,
|
||||
},
|
||||
'tag',
|
||||
)}
|
||||
</div>
|
||||
<div className='space-y-2'>
|
||||
{createSkeletonRect(
|
||||
{
|
||||
...SKELETON_STYLES.description,
|
||||
width: '100%',
|
||||
height: SIZES.description.height,
|
||||
},
|
||||
'desc1',
|
||||
)}
|
||||
{createSkeletonRect(
|
||||
{
|
||||
...SKELETON_STYLES.description,
|
||||
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
||||
width: '75%',
|
||||
height: SIZES.description.height,
|
||||
},
|
||||
'desc2',
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='flex-shrink-0 w-16 h-16 rounded-2xl bg-white/90 shadow-md backdrop-blur-sm flex items-center justify-center'>
|
||||
{createSkeletonRect(
|
||||
{
|
||||
...SKELETON_STYLES.avatar(isAllVendors),
|
||||
width: SIZES.avatar.width,
|
||||
height: SIZES.avatar.height,
|
||||
},
|
||||
'avatar',
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<div className='flex items-center gap-2 w-full'>
|
||||
<div className='flex-1'>
|
||||
{createSkeletonRect(
|
||||
{
|
||||
...SKELETON_STYLES.searchInput,
|
||||
width: '100%',
|
||||
height: SIZES.searchInput.height,
|
||||
},
|
||||
'search',
|
||||
)}
|
||||
</div>
|
||||
|
||||
{createSkeletonRect(
|
||||
{
|
||||
...SKELETON_STYLES.button,
|
||||
width: SIZES.button.width,
|
||||
height: SIZES.button.height,
|
||||
},
|
||||
'copy-button',
|
||||
)}
|
||||
|
||||
{isMobile &&
|
||||
createSkeletonRect(
|
||||
{
|
||||
...SKELETON_STYLES.button,
|
||||
width: SIZES.button.width,
|
||||
height: SIZES.button.height,
|
||||
},
|
||||
'filter-button',
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
|
||||
return (
|
||||
<Skeleton loading={true} active placeholder={placeholder}></Skeleton>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
PricingVendorIntroSkeleton.displayName = 'PricingVendorIntroSkeleton';
|
||||
|
||||
export default PricingVendorIntroSkeleton;
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
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, { memo } from 'react';
|
||||
import PricingVendorIntro from './PricingVendorIntro';
|
||||
import PricingVendorIntroSkeleton from './PricingVendorIntroSkeleton';
|
||||
import { useMinimumLoadingTime } from '../../../../../hooks/common/useMinimumLoadingTime';
|
||||
|
||||
const PricingVendorIntroWithSkeleton = memo(
|
||||
({ loading = false, filterVendor, ...restProps }) => {
|
||||
const showSkeleton = useMinimumLoadingTime(loading);
|
||||
|
||||
if (showSkeleton) {
|
||||
return (
|
||||
<PricingVendorIntroSkeleton
|
||||
isAllVendors={filterVendor === 'all'}
|
||||
isMobile={restProps.isMobile}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return <PricingVendorIntro filterVendor={filterVendor} {...restProps} />;
|
||||
},
|
||||
);
|
||||
|
||||
PricingVendorIntroWithSkeleton.displayName = 'PricingVendorIntroWithSkeleton';
|
||||
|
||||
export default PricingVendorIntroWithSkeleton;
|
||||
@@ -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, { memo, useCallback } from 'react';
|
||||
import { Input, Button, Switch, Select, Divider } from '@douyinfe/semi-ui';
|
||||
import { IconSearch, IconCopy, IconFilter } from '@douyinfe/semi-icons';
|
||||
|
||||
const SearchActions = memo(
|
||||
({
|
||||
selectedRowKeys = [],
|
||||
copyText,
|
||||
handleChange,
|
||||
handleCompositionStart,
|
||||
handleCompositionEnd,
|
||||
isMobile = false,
|
||||
searchValue = '',
|
||||
setShowFilterModal,
|
||||
showWithRecharge,
|
||||
setShowWithRecharge,
|
||||
currency,
|
||||
setCurrency,
|
||||
viewMode,
|
||||
setViewMode,
|
||||
tokenUnit,
|
||||
setTokenUnit,
|
||||
t,
|
||||
}) => {
|
||||
const handleCopyClick = useCallback(() => {
|
||||
if (copyText && selectedRowKeys.length > 0) {
|
||||
copyText(selectedRowKeys);
|
||||
}
|
||||
}, [copyText, selectedRowKeys]);
|
||||
|
||||
const handleFilterClick = useCallback(() => {
|
||||
setShowFilterModal?.(true);
|
||||
}, [setShowFilterModal]);
|
||||
|
||||
const handleViewModeToggle = useCallback(() => {
|
||||
setViewMode?.(viewMode === 'table' ? 'card' : 'table');
|
||||
}, [viewMode, setViewMode]);
|
||||
|
||||
const handleTokenUnitToggle = useCallback(() => {
|
||||
setTokenUnit?.(tokenUnit === 'K' ? 'M' : 'K');
|
||||
}, [tokenUnit, setTokenUnit]);
|
||||
|
||||
return (
|
||||
<div className='flex items-center gap-2 w-full'>
|
||||
<div className='flex-1'>
|
||||
<Input
|
||||
prefix={<IconSearch />}
|
||||
placeholder={t('模糊搜索模型名称')}
|
||||
value={searchValue}
|
||||
onCompositionStart={handleCompositionStart}
|
||||
onCompositionEnd={handleCompositionEnd}
|
||||
onChange={handleChange}
|
||||
showClear
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
theme='outline'
|
||||
type='tertiary'
|
||||
icon={<IconCopy style={{ color: '#ffffff' }} />}
|
||||
onClick={handleCopyClick}
|
||||
disabled={selectedRowKeys.length === 0}
|
||||
className='!bg-blue-500 hover:!bg-blue-600 disabled:!bg-gray-300'
|
||||
style={{ color: '#ffffff' }}
|
||||
>
|
||||
{t('复制')}
|
||||
</Button>
|
||||
|
||||
{!isMobile && (
|
||||
<>
|
||||
<Divider layout='vertical' margin='8px' />
|
||||
|
||||
{/* 充值价格显示开关 */}
|
||||
<div className='flex items-center gap-2'>
|
||||
<span className='text-sm text-gray-600'>{t('充值价格显示')}</span>
|
||||
<Switch
|
||||
checked={showWithRecharge}
|
||||
onChange={setShowWithRecharge}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 货币单位选择 */}
|
||||
{showWithRecharge && (
|
||||
<Select
|
||||
value={currency}
|
||||
onChange={setCurrency}
|
||||
optionList={[
|
||||
{ value: 'USD', label: 'USD' },
|
||||
{ value: 'CNY', label: 'CNY' },
|
||||
{ value: 'CUSTOM', label: t('自定义货币') },
|
||||
]}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 视图模式切换按钮 */}
|
||||
<Button
|
||||
theme={viewMode === 'table' ? 'solid' : 'outline'}
|
||||
type={viewMode === 'table' ? 'primary' : 'tertiary'}
|
||||
onClick={handleViewModeToggle}
|
||||
>
|
||||
{t('表格视图')}
|
||||
</Button>
|
||||
|
||||
{/* Token单位切换按钮 */}
|
||||
<Button
|
||||
theme={tokenUnit === 'K' ? 'solid' : 'outline'}
|
||||
type={tokenUnit === 'K' ? 'primary' : 'tertiary'}
|
||||
onClick={handleTokenUnitToggle}
|
||||
>
|
||||
{tokenUnit}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
|
||||
{isMobile && (
|
||||
<Button
|
||||
theme='outline'
|
||||
type='tertiary'
|
||||
icon={<IconFilter />}
|
||||
onClick={handleFilterClick}
|
||||
>
|
||||
{t('筛选')}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
SearchActions.displayName = 'SearchActions';
|
||||
|
||||
export default SearchActions;
|
||||
@@ -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;
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
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;
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
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;
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
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;
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
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 { FileText, Sparkles } from 'lucide-react';
|
||||
import { stringToColor } from '../../../../../helpers';
|
||||
|
||||
const ModelBasicInfo = ({ modelData, vendorsMap = {}, t }) => {
|
||||
// 获取模型描述
|
||||
const getModelDescription = () => {
|
||||
if (!modelData) return t('暂无模型描述');
|
||||
if (modelData.description) return modelData.description;
|
||||
if (modelData.vendor_description)
|
||||
return t('供应商信息:') + modelData.vendor_description;
|
||||
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();
|
||||
|
||||
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>
|
||||
|
||||
{/* 标签区域 */}
|
||||
{tags.length > 0 && (
|
||||
<div className='flex flex-wrap gap-1.5'>
|
||||
{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>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelBasicInfo;
|
||||
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
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 { Plug, Zap, ArrowRight, Globe } from 'lucide-react';
|
||||
|
||||
const ModelEndpoints = ({ modelData, endpointMap = {}, t }) => {
|
||||
const types = modelData?.supported_endpoint_types || [];
|
||||
|
||||
const getEndpointInfo = (type) => {
|
||||
const info = endpointMap[type] || {};
|
||||
let path = info.path || '';
|
||||
if (path.includes('{model}')) {
|
||||
const modelName = modelData?.model_name || modelData?.modelName || '';
|
||||
path = path.replaceAll('{model}', modelName);
|
||||
}
|
||||
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' />
|
||||
{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>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</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>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelEndpoints;
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
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 { Typography, Toast, Avatar } from '@douyinfe/semi-ui';
|
||||
import { getLobeHubIcon } from '../../../../../helpers';
|
||||
|
||||
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>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelHeader;
|
||||
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
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 {
|
||||
Coins,
|
||||
ChevronRight,
|
||||
Layers,
|
||||
Calculator,
|
||||
BadgePercent,
|
||||
} from 'lucide-react';
|
||||
import {
|
||||
calculateModelPrice,
|
||||
formatOfficialPriceDisplay,
|
||||
getDiscountBadgeText,
|
||||
} from '../../../../../helpers';
|
||||
|
||||
const ModelPricingTable = ({
|
||||
modelData,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
currency,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
showRatio,
|
||||
usableGroup,
|
||||
autoGroups = [],
|
||||
t,
|
||||
}) => {
|
||||
const modelEnableGroups = Array.isArray(modelData?.enable_groups)
|
||||
? modelData.enable_groups
|
||||
: [];
|
||||
const autoChain = autoGroups.filter((g) => modelEnableGroups.includes(g));
|
||||
|
||||
const availableGroups = Object.keys(usableGroup || {})
|
||||
.filter((g) => g !== '' && g !== 'auto')
|
||||
.filter((g) => modelEnableGroups.includes(g));
|
||||
|
||||
const getPriceData = (group) => {
|
||||
return modelData
|
||||
? calculateModelPrice({
|
||||
record: modelData,
|
||||
selectedGroup: group,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
currency,
|
||||
})
|
||||
: { inputPrice: '-', outputPrice: '-', price: '-' };
|
||||
};
|
||||
|
||||
const isPerToken = modelData?.quota_type === 0;
|
||||
const isPerSecond = modelData?.quota_type === 2;
|
||||
const isPerImageResolution = modelData?.quota_type === 3;
|
||||
|
||||
// 官方价参考行:仅当至少一个可用分组的实付价低于官方牌价时展示
|
||||
//(与卡片折扣徽标同一保守口径,避免展示「站内比官方还贵」的对照)
|
||||
const groupPriceDataList = availableGroups.map((g) => getPriceData(g));
|
||||
const hasAnyDiscount = groupPriceDataList.some((pd) => pd?.discountBadge);
|
||||
const officialDisplay =
|
||||
hasAnyDiscount && modelData?.official_price
|
||||
? formatOfficialPriceDisplay({
|
||||
official: modelData.official_price,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
})
|
||||
: null;
|
||||
const billingLabel = isPerSecond
|
||||
? t('按秒计费')
|
||||
: isPerImageResolution
|
||||
? t('按分辨率计费')
|
||||
: isPerToken
|
||||
? t('按量计费')
|
||||
: t('按次计费');
|
||||
const tokenLabel = tokenUnit === 'K' ? '1K' : '1M';
|
||||
const samplePriceData = isPerToken
|
||||
? getPriceData(availableGroups[0] || 'all')
|
||||
: null;
|
||||
const extraPriceColumns = Array.isArray(samplePriceData?.extraPrices)
|
||||
? samplePriceData.extraPrices
|
||||
: [];
|
||||
// 按秒分档:列 = 各档位,由配置顺序决定
|
||||
const videoTierColumns = 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;
|
||||
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;
|
||||
|
||||
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>
|
||||
</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' />
|
||||
<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' />
|
||||
)}
|
||||
</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>
|
||||
);
|
||||
};
|
||||
|
||||
export default ModelPricingTable;
|
||||
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
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 { Card, Skeleton } from '@douyinfe/semi-ui';
|
||||
|
||||
const PricingCardSkeleton = ({
|
||||
skeletonCount = 100,
|
||||
rowSelection = false,
|
||||
showRatio = false,
|
||||
}) => {
|
||||
const placeholder = (
|
||||
<div className='px-2 pt-2'>
|
||||
<div className='grid grid-cols-1 xl:grid-cols-2 2xl:grid-cols-3 gap-4'>
|
||||
{Array.from({ length: skeletonCount }).map((_, index) => (
|
||||
<Card
|
||||
key={index}
|
||||
className='!rounded-2xl border border-gray-200'
|
||||
bodyStyle={{ padding: '24px' }}
|
||||
>
|
||||
{/* 头部:图标 + 模型名称 + 操作按钮 */}
|
||||
<div className='flex items-start justify-between mb-3'>
|
||||
<div className='flex items-start space-x-3 flex-1 min-w-0'>
|
||||
{/* 模型图标骨架 */}
|
||||
<div className='w-12 h-12 rounded-2xl flex items-center justify-center relative shadow-sm'>
|
||||
<Skeleton.Avatar
|
||||
size='large'
|
||||
style={{ width: 48, height: 48, borderRadius: 16 }}
|
||||
/>
|
||||
</div>
|
||||
{/* 模型名称和价格区域 */}
|
||||
<div className='flex-1 min-w-0'>
|
||||
{/* 模型名称骨架 */}
|
||||
<Skeleton.Title
|
||||
style={{
|
||||
width: `${120 + (index % 3) * 30}px`,
|
||||
height: 20,
|
||||
marginBottom: 8,
|
||||
}}
|
||||
/>
|
||||
{/* 价格信息骨架 */}
|
||||
<Skeleton.Title
|
||||
style={{
|
||||
width: `${160 + (index % 4) * 20}px`,
|
||||
height: 20,
|
||||
marginBottom: 0,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='flex items-center space-x-2 ml-3'>
|
||||
{/* 复制按钮骨架 */}
|
||||
<Skeleton.Button
|
||||
size='small'
|
||||
style={{ width: 16, height: 16, borderRadius: 4 }}
|
||||
/>
|
||||
{/* 勾选框骨架 */}
|
||||
{rowSelection && (
|
||||
<Skeleton.Button
|
||||
size='small'
|
||||
style={{ width: 16, height: 16, borderRadius: 2 }}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 模型描述骨架 */}
|
||||
<div className='mb-4'>
|
||||
<Skeleton.Paragraph
|
||||
rows={2}
|
||||
style={{ marginBottom: 0 }}
|
||||
title={false}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* 标签区域骨架 */}
|
||||
<div className='flex flex-wrap gap-2'>
|
||||
{Array.from({ length: 2 + (index % 3) }).map((_, tagIndex) => (
|
||||
<Skeleton.Button
|
||||
key={tagIndex}
|
||||
size='small'
|
||||
style={{
|
||||
width: 64,
|
||||
height: 18,
|
||||
borderRadius: 10,
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* 倍率信息骨架(可选) */}
|
||||
{showRatio && (
|
||||
<div className='mt-4 pt-3 border-t border-gray-100'>
|
||||
<div className='flex items-center space-x-1 mb-2'>
|
||||
<Skeleton.Title
|
||||
style={{ width: 60, height: 12, marginBottom: 0 }}
|
||||
/>
|
||||
<Skeleton.Button
|
||||
size='small'
|
||||
style={{ width: 14, height: 14, borderRadius: 7 }}
|
||||
/>
|
||||
</div>
|
||||
<div className='grid grid-cols-3 gap-2'>
|
||||
{Array.from({ length: 3 }).map((_, ratioIndex) => (
|
||||
<Skeleton.Title
|
||||
key={ratioIndex}
|
||||
style={{ width: '100%', height: 12, marginBottom: 0 }}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* 分页骨架 */}
|
||||
<div className='flex justify-center mt-6 py-4 border-t pricing-pagination-divider'>
|
||||
<Skeleton.Button style={{ width: 300, height: 32 }} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
return <Skeleton loading={true} active placeholder={placeholder}></Skeleton>;
|
||||
};
|
||||
|
||||
export default PricingCardSkeleton;
|
||||
@@ -0,0 +1,396 @@
|
||||
/*
|
||||
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 {
|
||||
Card,
|
||||
Tag,
|
||||
Tooltip,
|
||||
Checkbox,
|
||||
Empty,
|
||||
Pagination,
|
||||
Button,
|
||||
Avatar,
|
||||
} from '@douyinfe/semi-ui';
|
||||
import { IconHelpCircle } from '@douyinfe/semi-icons';
|
||||
import { Copy } from 'lucide-react';
|
||||
import {
|
||||
IllustrationNoResult,
|
||||
IllustrationNoResultDark,
|
||||
} from '../../../../common/illustrations';
|
||||
import {
|
||||
stringToColor,
|
||||
calculateModelPrice,
|
||||
formatPriceInfo,
|
||||
getLobeHubIcon,
|
||||
} from '../../../../../helpers';
|
||||
import PricingCardSkeleton from './PricingCardSkeleton';
|
||||
import { useMinimumLoadingTime } from '../../../../../hooks/common/useMinimumLoadingTime';
|
||||
import { renderLimitedItems } from '../../../../common/ui/RenderUtils';
|
||||
import { useIsMobile } from '../../../../../hooks/common/useIsMobile';
|
||||
|
||||
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',
|
||||
selected: 'border-blue-500 bg-blue-50',
|
||||
default: 'border-gray-200 hover:border-gray-300',
|
||||
};
|
||||
|
||||
const PricingCardView = ({
|
||||
filteredModels,
|
||||
loading,
|
||||
rowSelection,
|
||||
pageSize,
|
||||
setPageSize,
|
||||
currentPage,
|
||||
setCurrentPage,
|
||||
selectedGroup,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
copyText,
|
||||
setModalImageUrl,
|
||||
setIsModalOpenurl,
|
||||
currency,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
showRatio,
|
||||
t,
|
||||
selectedRowKeys = [],
|
||||
setSelectedRowKeys,
|
||||
openModelDetail,
|
||||
}) => {
|
||||
const showSkeleton = useMinimumLoadingTime(loading);
|
||||
const startIndex = (currentPage - 1) * pageSize;
|
||||
const paginatedModels = filteredModels.slice(
|
||||
startIndex,
|
||||
startIndex + pageSize,
|
||||
);
|
||||
const getModelKey = (model) => model.key ?? model.model_name ?? model.id;
|
||||
const isMobile = useIsMobile();
|
||||
|
||||
const handleCheckboxChange = (model, checked) => {
|
||||
if (!setSelectedRowKeys) return;
|
||||
const modelKey = getModelKey(model);
|
||||
const newKeys = checked
|
||||
? Array.from(new Set([...selectedRowKeys, modelKey]))
|
||||
: selectedRowKeys.filter((key) => key !== modelKey);
|
||||
setSelectedRowKeys(newKeys);
|
||||
rowSelection?.onChange?.(newKeys, null);
|
||||
};
|
||||
|
||||
// 获取模型图标
|
||||
const getModelIcon = (model) => {
|
||||
if (!model || !model.model_name) {
|
||||
return (
|
||||
<div className={CARD_STYLES.container}>
|
||||
<Avatar size='large'>?</Avatar>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
// 1) 优先使用模型自定义图标
|
||||
if (model.icon) {
|
||||
return (
|
||||
<div className={CARD_STYLES.container}>
|
||||
<div className={CARD_STYLES.icon}>
|
||||
{getLobeHubIcon(model.icon, 32)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
// 2) 退化为供应商图标
|
||||
if (model.vendor_icon) {
|
||||
return (
|
||||
<div className={CARD_STYLES.container}>
|
||||
<div className={CARD_STYLES.icon}>
|
||||
{getLobeHubIcon(model.vendor_icon, 32)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 如果没有供应商图标,使用模型名称生成头像
|
||||
|
||||
const avatarText = model.model_name.slice(0, 2).toUpperCase();
|
||||
return (
|
||||
<div className={CARD_STYLES.container}>
|
||||
<Avatar
|
||||
size='large'
|
||||
style={{
|
||||
width: 48,
|
||||
height: 48,
|
||||
borderRadius: 16,
|
||||
fontSize: 16,
|
||||
fontWeight: 'bold',
|
||||
}}
|
||||
>
|
||||
{avatarText}
|
||||
</Avatar>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// 获取模型描述
|
||||
const getModelDescription = (record) => {
|
||||
return record.description || '';
|
||||
};
|
||||
|
||||
// 渲染标签
|
||||
const renderTags = (record) => {
|
||||
// 计费类型标签(左边)
|
||||
let billingTag = (
|
||||
<Tag key='billing' shape='circle' color='white' size='small'>
|
||||
-
|
||||
</Tag>
|
||||
);
|
||||
if (record.quota_type === 3) {
|
||||
billingTag = (
|
||||
<Tag key='billing' shape='circle' color='blue' size='small'>
|
||||
{t('按分辨率计费')}
|
||||
</Tag>
|
||||
);
|
||||
} else if (record.quota_type === 2) {
|
||||
billingTag = (
|
||||
<Tag key='billing' shape='circle' color='green' size='small'>
|
||||
{t('按秒计费')}
|
||||
</Tag>
|
||||
);
|
||||
} else if (record.quota_type === 1) {
|
||||
billingTag = (
|
||||
<Tag key='billing' shape='circle' color='teal' size='small'>
|
||||
{t('按次计费')}
|
||||
</Tag>
|
||||
);
|
||||
} else if (record.quota_type === 0) {
|
||||
billingTag = (
|
||||
<Tag key='billing' shape='circle' color='violet' size='small'>
|
||||
{t('按量计费')}
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
|
||||
// 自定义标签(右边)
|
||||
const customTags = [];
|
||||
if (record.tags) {
|
||||
const tagArr = record.tags.split(',').filter(Boolean);
|
||||
tagArr.forEach((tg, idx) => {
|
||||
customTags.push(
|
||||
<Tag
|
||||
key={`custom-${idx}`}
|
||||
shape='circle'
|
||||
color={stringToColor(tg)}
|
||||
size='small'
|
||||
>
|
||||
{tg}
|
||||
</Tag>,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='flex items-center justify-between'>
|
||||
<div className='flex items-center gap-2'>{billingTag}</div>
|
||||
<div className='flex items-center gap-1'>
|
||||
{customTags.length > 0 &&
|
||||
renderLimitedItems({
|
||||
items: customTags.map((tag, idx) => ({
|
||||
key: `custom-${idx}`,
|
||||
element: tag,
|
||||
})),
|
||||
renderItem: (item, idx) => item.element,
|
||||
maxDisplay: 3,
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// 显示骨架屏
|
||||
if (showSkeleton) {
|
||||
return (
|
||||
<PricingCardSkeleton
|
||||
rowSelection={!!rowSelection}
|
||||
showRatio={showRatio}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (!filteredModels || filteredModels.length === 0) {
|
||||
return (
|
||||
<div className='flex justify-center items-center py-20'>
|
||||
<Empty
|
||||
image={<IllustrationNoResult style={{ width: 150, height: 150 }} />}
|
||||
darkModeImage={
|
||||
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
|
||||
}
|
||||
description={t('搜索无结果')}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='px-2 pt-2'>
|
||||
<div className='grid grid-cols-1 xl:grid-cols-2 2xl:grid-cols-3 gap-4'>
|
||||
{paginatedModels.map((model, index) => {
|
||||
const modelKey = getModelKey(model);
|
||||
const isSelected = selectedRowKeys.includes(modelKey);
|
||||
|
||||
const priceData = calculateModelPrice({
|
||||
record: model,
|
||||
selectedGroup,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
currency,
|
||||
});
|
||||
|
||||
return (
|
||||
<Card
|
||||
key={modelKey || index}
|
||||
className={`!rounded-2xl transition-all duration-200 hover:shadow-lg border cursor-pointer ${isSelected ? CARD_STYLES.selected : CARD_STYLES.default}`}
|
||||
bodyStyle={{ height: '100%' }}
|
||||
onClick={() => openModelDetail && openModelDetail(model)}
|
||||
>
|
||||
<div className='flex flex-col h-full'>
|
||||
{/* 头部:图标 + 模型名称 + 操作按钮 */}
|
||||
<div className='flex items-start justify-between mb-3'>
|
||||
<div className='flex items-start space-x-3 flex-1 min-w-0'>
|
||||
{getModelIcon(model)}
|
||||
<div className='flex-1 min-w-0'>
|
||||
<h3 className='text-lg font-bold text-gray-900 truncate'>
|
||||
{model.model_name}
|
||||
</h3>
|
||||
<div className='flex items-center gap-3 text-xs mt-1'>
|
||||
{formatPriceInfo(priceData, t)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='flex items-center space-x-2 ml-3'>
|
||||
{/* 复制按钮 */}
|
||||
<Button
|
||||
size='small'
|
||||
theme='outline'
|
||||
type='tertiary'
|
||||
icon={<Copy size={12} />}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
copyText(model.model_name);
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* 选择框 */}
|
||||
{rowSelection && (
|
||||
<Checkbox
|
||||
checked={isSelected}
|
||||
onChange={(e) => {
|
||||
e.stopPropagation();
|
||||
handleCheckboxChange(model, e.target.checked);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 模型描述 - 占据剩余空间 */}
|
||||
<div className='flex-1 mb-4'>
|
||||
<p
|
||||
className='text-xs line-clamp-2 leading-relaxed'
|
||||
style={{ color: 'var(--semi-color-text-2)' }}
|
||||
>
|
||||
{getModelDescription(model)}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 底部区域 */}
|
||||
<div className='mt-auto'>
|
||||
{/* 标签区域 */}
|
||||
{renderTags(model)}
|
||||
|
||||
{/* 倍率信息(可选) */}
|
||||
{showRatio && (
|
||||
<div className='pt-3'>
|
||||
<div className='flex items-center space-x-1 mb-2'>
|
||||
<span className='text-xs font-medium text-gray-700'>
|
||||
{t('倍率信息')}
|
||||
</span>
|
||||
<Tooltip
|
||||
content={t('倍率是为了方便换算不同价格的模型')}
|
||||
>
|
||||
<IconHelpCircle
|
||||
className='text-blue-500 cursor-pointer'
|
||||
size='small'
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setModalImageUrl('/ratio.png');
|
||||
setIsModalOpenurl(true);
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<div className='grid grid-cols-3 gap-2 text-xs text-gray-600'>
|
||||
<div>
|
||||
{t('模型')}:{' '}
|
||||
{model.quota_type === 0 ? model.model_ratio : t('无')}
|
||||
</div>
|
||||
<div>
|
||||
{t('补全')}:{' '}
|
||||
{model.quota_type === 0
|
||||
? parseFloat(model.completion_ratio.toFixed(3))
|
||||
: t('无')}
|
||||
</div>
|
||||
<div>
|
||||
{t('分组')}: {priceData?.usedGroupRatio ?? '-'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* 分页 */}
|
||||
{filteredModels.length > 0 && (
|
||||
<div className='flex justify-center mt-6 py-4 border-t pricing-pagination-divider'>
|
||||
<Pagination
|
||||
currentPage={currentPage}
|
||||
pageSize={pageSize}
|
||||
total={filteredModels.length}
|
||||
showSizeChanger={true}
|
||||
pageSizeOptions={[10, 20, 50, 100]}
|
||||
size={isMobile ? 'small' : 'default'}
|
||||
showQuickJumper={isMobile}
|
||||
onPageChange={(page) => setCurrentPage(page)}
|
||||
onPageSizeChange={(size) => {
|
||||
setPageSize(size);
|
||||
setCurrentPage(1);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PricingCardView;
|
||||
@@ -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, { useMemo } from 'react';
|
||||
import { Card, Table, Empty } from '@douyinfe/semi-ui';
|
||||
import {
|
||||
IllustrationNoResult,
|
||||
IllustrationNoResultDark,
|
||||
} from '../../../../common/illustrations';
|
||||
import { getPricingTableColumns } from './PricingTableColumns';
|
||||
import { useIsMobile } from '../../../../../hooks/common/useIsMobile';
|
||||
|
||||
const PricingTable = ({
|
||||
filteredModels,
|
||||
loading,
|
||||
rowSelection,
|
||||
pageSize,
|
||||
setPageSize,
|
||||
selectedGroup,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
copyText,
|
||||
setModalImageUrl,
|
||||
setIsModalOpenurl,
|
||||
currency,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
searchValue,
|
||||
showRatio,
|
||||
compactMode = false,
|
||||
openModelDetail,
|
||||
t,
|
||||
}) => {
|
||||
const isMobile = useIsMobile();
|
||||
const columns = useMemo(() => {
|
||||
return getPricingTableColumns({
|
||||
t,
|
||||
selectedGroup,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
copyText,
|
||||
setModalImageUrl,
|
||||
setIsModalOpenurl,
|
||||
currency,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
showRatio,
|
||||
isMobile,
|
||||
});
|
||||
}, [
|
||||
t,
|
||||
selectedGroup,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
copyText,
|
||||
setModalImageUrl,
|
||||
setIsModalOpenurl,
|
||||
currency,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
showRatio,
|
||||
isMobile,
|
||||
]);
|
||||
|
||||
// 更新列定义中的 searchValue
|
||||
const processedColumns = useMemo(() => {
|
||||
const cols = columns.map((column) => {
|
||||
if (column.dataIndex === 'model_name') {
|
||||
return {
|
||||
...column,
|
||||
filteredValue: searchValue ? [searchValue] : [],
|
||||
};
|
||||
}
|
||||
return column;
|
||||
});
|
||||
|
||||
// Remove fixed property when in compact mode (mobile view)
|
||||
if (compactMode) {
|
||||
return cols.map(({ fixed, ...rest }) => rest);
|
||||
}
|
||||
return cols;
|
||||
}, [columns, searchValue, compactMode]);
|
||||
|
||||
const ModelTable = useMemo(
|
||||
() => (
|
||||
<Card className='!rounded-xl overflow-hidden' bordered={false}>
|
||||
<Table
|
||||
columns={processedColumns}
|
||||
dataSource={filteredModels}
|
||||
loading={loading}
|
||||
rowSelection={rowSelection}
|
||||
scroll={compactMode ? undefined : { x: 'max-content' }}
|
||||
onRow={(record) => ({
|
||||
onClick: () => openModelDetail && openModelDetail(record),
|
||||
style: { cursor: 'pointer' },
|
||||
})}
|
||||
empty={
|
||||
<Empty
|
||||
image={
|
||||
<IllustrationNoResult style={{ width: 150, height: 150 }} />
|
||||
}
|
||||
darkModeImage={
|
||||
<IllustrationNoResultDark style={{ width: 150, height: 150 }} />
|
||||
}
|
||||
description={t('搜索无结果')}
|
||||
style={{ padding: 30 }}
|
||||
/>
|
||||
}
|
||||
pagination={{
|
||||
defaultPageSize: 20,
|
||||
pageSize: pageSize,
|
||||
showSizeChanger: true,
|
||||
pageSizeOptions: [10, 20, 50, 100],
|
||||
onPageSizeChange: (size) => setPageSize(size),
|
||||
}}
|
||||
/>
|
||||
</Card>
|
||||
),
|
||||
[
|
||||
filteredModels,
|
||||
loading,
|
||||
processedColumns,
|
||||
rowSelection,
|
||||
pageSize,
|
||||
setPageSize,
|
||||
openModelDetail,
|
||||
t,
|
||||
compactMode,
|
||||
],
|
||||
);
|
||||
|
||||
return ModelTable;
|
||||
};
|
||||
|
||||
export default PricingTable;
|
||||
@@ -0,0 +1,322 @@
|
||||
/*
|
||||
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 { Tag, Space, Tooltip } from '@douyinfe/semi-ui';
|
||||
import { IconHelpCircle } from '@douyinfe/semi-icons';
|
||||
import {
|
||||
renderModelTag,
|
||||
stringToColor,
|
||||
calculateModelPrice,
|
||||
getLobeHubIcon,
|
||||
} from '../../../../../helpers';
|
||||
import {
|
||||
renderLimitedItems,
|
||||
renderDescription,
|
||||
} from '../../../../common/ui/RenderUtils';
|
||||
|
||||
function renderQuotaType(type, t) {
|
||||
switch (type) {
|
||||
case 3:
|
||||
return (
|
||||
<Tag color='blue' shape='circle'>
|
||||
{t('按分辨率计费')}
|
||||
</Tag>
|
||||
);
|
||||
case 2:
|
||||
return (
|
||||
<Tag color='green' shape='circle'>
|
||||
{t('按秒计费')}
|
||||
</Tag>
|
||||
);
|
||||
case 1:
|
||||
return (
|
||||
<Tag color='teal' shape='circle'>
|
||||
{t('按次计费')}
|
||||
</Tag>
|
||||
);
|
||||
case 0:
|
||||
return (
|
||||
<Tag color='violet' shape='circle'>
|
||||
{t('按量计费')}
|
||||
</Tag>
|
||||
);
|
||||
default:
|
||||
return t('未知');
|
||||
}
|
||||
}
|
||||
|
||||
// Render vendor name
|
||||
const renderVendor = (vendorName, vendorIcon, t) => {
|
||||
if (!vendorName) return '-';
|
||||
return (
|
||||
<Tag
|
||||
color='white'
|
||||
shape='circle'
|
||||
prefixIcon={getLobeHubIcon(vendorIcon || 'Layers', 14)}
|
||||
>
|
||||
{vendorName}
|
||||
</Tag>
|
||||
);
|
||||
};
|
||||
|
||||
// Render tags list using RenderUtils
|
||||
const renderTags = (text) => {
|
||||
if (!text) return '-';
|
||||
const tagsArr = text.split(',').filter((tag) => tag.trim());
|
||||
return renderLimitedItems({
|
||||
items: tagsArr,
|
||||
renderItem: (tag, idx) => (
|
||||
<Tag
|
||||
key={idx}
|
||||
color={stringToColor(tag.trim())}
|
||||
shape='circle'
|
||||
size='small'
|
||||
>
|
||||
{tag.trim()}
|
||||
</Tag>
|
||||
),
|
||||
maxDisplay: 3,
|
||||
});
|
||||
};
|
||||
|
||||
function renderSupportedEndpoints(endpoints) {
|
||||
if (!endpoints || endpoints.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<Space wrap>
|
||||
{endpoints.map((endpoint, idx) => (
|
||||
<Tag key={endpoint} color={stringToColor(endpoint)} shape='circle'>
|
||||
{endpoint}
|
||||
</Tag>
|
||||
))}
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
|
||||
export const getPricingTableColumns = ({
|
||||
t,
|
||||
selectedGroup,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
copyText,
|
||||
setModalImageUrl,
|
||||
setIsModalOpenurl,
|
||||
currency,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
showRatio,
|
||||
isMobile = false,
|
||||
}) => {
|
||||
const priceDataCache = new WeakMap();
|
||||
|
||||
const getPriceData = (record) => {
|
||||
let cache = priceDataCache.get(record);
|
||||
if (!cache) {
|
||||
cache = calculateModelPrice({
|
||||
record,
|
||||
selectedGroup,
|
||||
groupRatio,
|
||||
groupModelDiscount,
|
||||
tokenUnit,
|
||||
displayPrice,
|
||||
currency,
|
||||
});
|
||||
priceDataCache.set(record, cache);
|
||||
}
|
||||
return cache;
|
||||
};
|
||||
|
||||
const endpointColumn = {
|
||||
title: t('可用端点类型'),
|
||||
dataIndex: 'supported_endpoint_types',
|
||||
render: (text, record, index) => {
|
||||
return renderSupportedEndpoints(text);
|
||||
},
|
||||
};
|
||||
|
||||
const modelNameColumn = {
|
||||
title: t('模型名称'),
|
||||
dataIndex: 'model_name',
|
||||
render: (text, record, index) => {
|
||||
return renderModelTag(text, {
|
||||
onClick: () => {
|
||||
copyText(text);
|
||||
},
|
||||
});
|
||||
},
|
||||
onFilter: (value, record) =>
|
||||
record.model_name.toLowerCase().includes(value.toLowerCase()),
|
||||
};
|
||||
|
||||
const quotaColumn = {
|
||||
title: t('计费类型'),
|
||||
dataIndex: 'quota_type',
|
||||
render: (text, record, index) => {
|
||||
return renderQuotaType(parseInt(text), t);
|
||||
},
|
||||
sorter: (a, b) => a.quota_type - b.quota_type,
|
||||
};
|
||||
|
||||
const descriptionColumn = {
|
||||
title: t('描述'),
|
||||
dataIndex: 'description',
|
||||
render: (text) => renderDescription(text, 200),
|
||||
};
|
||||
|
||||
const tagsColumn = {
|
||||
title: t('标签'),
|
||||
dataIndex: 'tags',
|
||||
render: renderTags,
|
||||
};
|
||||
|
||||
const vendorColumn = {
|
||||
title: t('供应商'),
|
||||
dataIndex: 'vendor_name',
|
||||
render: (text, record) => renderVendor(text, record.vendor_icon, t),
|
||||
};
|
||||
|
||||
const baseColumns = [
|
||||
modelNameColumn,
|
||||
vendorColumn,
|
||||
descriptionColumn,
|
||||
tagsColumn,
|
||||
quotaColumn,
|
||||
];
|
||||
|
||||
const ratioColumn = {
|
||||
title: () => (
|
||||
<div className='flex items-center space-x-1'>
|
||||
<span>{t('倍率')}</span>
|
||||
<Tooltip content={t('倍率是为了方便换算不同价格的模型')}>
|
||||
<IconHelpCircle
|
||||
className='text-blue-500 cursor-pointer'
|
||||
onClick={() => {
|
||||
setModalImageUrl('/ratio.png');
|
||||
setIsModalOpenurl(true);
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
),
|
||||
dataIndex: 'model_ratio',
|
||||
render: (text, record, index) => {
|
||||
const completionRatio = parseFloat(record.completion_ratio.toFixed(3));
|
||||
const priceData = getPriceData(record);
|
||||
|
||||
return (
|
||||
<div className='space-y-1'>
|
||||
<div className='text-gray-700'>
|
||||
{t('模型倍率')}:{record.quota_type === 0 ? text : t('无')}
|
||||
</div>
|
||||
<div className='text-gray-700'>
|
||||
{t('补全倍率')}:
|
||||
{record.quota_type === 0 ? completionRatio : t('无')}
|
||||
</div>
|
||||
<div className='text-gray-700'>
|
||||
{t('分组倍率')}:{priceData?.usedGroupRatio ?? '-'}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
const priceColumn = {
|
||||
title: t('模型价格'),
|
||||
dataIndex: 'model_price',
|
||||
...(isMobile ? {} : { fixed: 'right' }),
|
||||
render: (text, record, index) => {
|
||||
const priceData = getPriceData(record);
|
||||
|
||||
if (priceData.isPerSecond) {
|
||||
const videoTiers = Array.isArray(priceData.videoTiers)
|
||||
? priceData.videoTiers
|
||||
: [];
|
||||
if (videoTiers.length === 0) {
|
||||
return <div className='text-gray-700'>-</div>;
|
||||
}
|
||||
return (
|
||||
<div className='space-y-1'>
|
||||
{videoTiers.map((tier) => (
|
||||
<div key={tier.key} className='text-gray-700'>
|
||||
{tier.label}:{tier.price} / {t('秒')}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (priceData.isPerImageResolution) {
|
||||
const imageTiers = Array.isArray(priceData.imageTiers)
|
||||
? priceData.imageTiers
|
||||
: [];
|
||||
if (imageTiers.length === 0) {
|
||||
return <div className='text-gray-700'>-</div>;
|
||||
}
|
||||
return (
|
||||
<div className='space-y-1'>
|
||||
{imageTiers.map((tier) => (
|
||||
<div key={tier.key} className='text-gray-700'>
|
||||
{tier.label}:{tier.price} / {t('张')}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (priceData.isPerToken) {
|
||||
const extraPrices = Array.isArray(priceData.extraPrices)
|
||||
? priceData.extraPrices
|
||||
: [];
|
||||
|
||||
return (
|
||||
<div className='space-y-1'>
|
||||
<div className='text-gray-700'>
|
||||
{t('输入')} {priceData.inputPrice} / 1{priceData.unitLabel} tokens
|
||||
</div>
|
||||
<div className='text-gray-700'>
|
||||
{t('输出')} {priceData.completionPrice} / 1{priceData.unitLabel}{' '}
|
||||
tokens
|
||||
</div>
|
||||
{extraPrices.map((item) => (
|
||||
<div key={item.key} className='text-gray-700'>
|
||||
{t(item.labelKey)} {item.price} / 1{priceData.unitLabel} tokens
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div className='text-gray-700'>
|
||||
{t('模型价格')}:{priceData.price}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const columns = [...baseColumns];
|
||||
columns.push(endpointColumn);
|
||||
if (showRatio) {
|
||||
columns.push(ratioColumn);
|
||||
}
|
||||
columns.push(priceColumn);
|
||||
return columns;
|
||||
};
|
||||
Reference in New Issue
Block a user