feat: 参考原型图 ui优化提交 个人端-用户中心 相关的页面

This commit is contained in:
zhanjunhao
2026-11-04 19:59:06 +08:00
parent 1fd4e084b6
commit 15192c433b
576 changed files with 18075 additions and 18912 deletions
@@ -1,267 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { 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);
@@ -1,318 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { 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;
@@ -1,117 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { 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;
@@ -1,295 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { 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;
@@ -1,239 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { 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;
@@ -1,242 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { 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;
@@ -1,107 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import 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;
@@ -18,14 +18,13 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup';
import MarketFilterGroup from '../market/MarketFilterGroup';
/**
* 端点类型筛选组件
* @param {string|'all'} filterEndpointType 当前值
* @param {Function} setFilterEndpointType setter
* @param {Array} models 模型列表
* @param {boolean} loading 是否加载中
* @param {Function} t i18n
*/
const PricingEndpointTypes = ({
@@ -33,7 +32,6 @@ const PricingEndpointTypes = ({
setFilterEndpointType,
models = [],
allModels = [],
loading = false,
t,
// 外层已有分区标题时传 null 隐藏内置标题(如 FilterDrawer),避免双标题
title,
@@ -92,13 +90,11 @@ const PricingEndpointTypes = ({
];
return (
<SelectableButtonGroup
<MarketFilterGroup
title={title === undefined ? t('端点类型') : title}
items={items}
activeValue={filterEndpointType}
onChange={setFilterEndpointType}
loading={loading}
t={t}
/>
);
};
@@ -18,7 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup';
import MarketFilterGroup from '../market/MarketFilterGroup';
/**
* 分组筛选组件
@@ -27,7 +27,6 @@ import SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup';
* @param {Record<string, any>} usableGroup 后端返回的可用分组对象
* @param {Record<string, number>} groupRatio 分组倍率对象
* @param {Array} models 模型列表
* @param {boolean} loading 是否加载中
* @param {boolean} showRatio 是否显示倍率
* @param {Function} t i18n
*/
@@ -37,7 +36,6 @@ const PricingGroups = ({
usableGroup = {},
groupRatio = {},
models = [],
loading = false,
showRatio = true,
t,
// 外层已有分区标题时传 null 隐藏内置标题(如 FilterDrawer),避免双标题
@@ -73,18 +71,18 @@ const PricingGroups = ({
value: g,
label: g === 'all' ? t('全部分组') : g,
tagCount: ratioDisplay,
// 原型按钮不显示计数;倍率展示开关开启时保留倍率文字
suffix: g !== 'all' && showRatio ? ratioDisplay : undefined,
disabled: modelCount === 0,
};
});
return (
<SelectableButtonGroup
<MarketFilterGroup
title={title === undefined ? t('可用令牌分组') : title}
items={items}
activeValue={filterGroup}
onChange={setFilterGroup}
loading={loading}
t={t}
/>
);
};
@@ -18,21 +18,19 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup';
import MarketFilterGroup from '../market/MarketFilterGroup';
/**
* 计费类型筛选组件
* @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,
@@ -50,13 +48,11 @@ const PricingQuotaTypes = ({
];
return (
<SelectableButtonGroup
<MarketFilterGroup
title={title === undefined ? t('计费类型') : title}
items={items}
activeValue={filterQuotaType}
onChange={setFilterQuotaType}
loading={loading}
t={t}
/>
);
};
@@ -18,7 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup';
import MarketFilterGroup from '../market/MarketFilterGroup';
/**
* 模型标签筛选组件
@@ -26,7 +26,6 @@ import SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup';
* @param {Function} setFilterTag setter
* @param {Array} models 当前过滤后模型列表(用于计数)
* @param {Array} allModels 所有模型列表(用于获取所有标签)
* @param {boolean} loading 是否加载中
* @param {Function} t i18n
*/
const PricingTags = ({
@@ -34,7 +33,6 @@ const PricingTags = ({
setFilterTag,
models = [],
allModels = [],
loading = false,
t,
// 外层已有分区标题时传 null 隐藏内置标题(如 FilterDrawer),避免双标题
title,
@@ -98,13 +96,11 @@ const PricingTags = ({
}, [getAllTags, getTagCount, t, models.length]);
return (
<SelectableButtonGroup
<MarketFilterGroup
title={title === undefined ? t('标签') : title}
items={items}
activeValue={filterTag}
onChange={setFilterTag}
loading={loading}
t={t}
/>
);
};
@@ -18,110 +18,57 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import SelectableButtonGroup from '../../../common/ui/SelectableButtonGroup';
import MarketFilterGroup from '../market/MarketFilterGroup';
import { getLobeHubIcon } from '../../../../helpers';
/**
* 供应商筛选组件
* 供应商(模型厂商)筛选组件。
*
* 选项规则沿用原吸顶筛选栏(FilterBar):只列出在完整模型列表里确有模型的供应商
*(vendorsMap 是全部供应商记录,模型可能被等级策略 / 渠道下线剔除),按名称排序;
* 不提供「未知供应商」项,点击直接调用原 setFilterVendor。
* @param {Record<string, {id:number,name:string,icon?:string}>} vendorsMap 供应商映射
* @param {string|'all'} filterVendor 当前值
* @param {Function} setFilterVendor setter
* @param {Array} models 模型列表
* @param {Array} allModels 所有模型列表(用于获取全部供应商)
* @param {boolean} loading 是否加载中
* @param {Array} allModels 完整模型列表(未经筛选)
* @param {Function} t i18n
*/
const PricingVendors = ({
vendorsMap = {},
filterVendor,
setFilterVendor,
models = [],
allModels = [],
loading = false,
t,
title,
}) => {
// 获取系统中所有供应商(基于 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;
}
const availableVendorNames = React.useMemo(() => {
const names = new Set();
(allModels || []).forEach((m) => {
if (m.vendor_name) names.add(m.vendor_name);
});
return names;
}, [allModels]);
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,
},
const vendorsList = Object.values(vendorsMap || {})
.filter((vendor) => availableVendorNames.has(vendor.name))
.sort((a, b) => a.name.localeCompare(b.name));
return [
{ value: 'all', label: t('全部厂商') },
...vendorsList.map((vendor) => ({
value: vendor.name,
label: vendor.name,
icon: vendor.icon ? getLobeHubIcon(vendor.icon, 18) : null,
})),
];
// 添加所有已知供应商
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]);
}, [vendorsMap, availableVendorNames, t]);
return (
<SelectableButtonGroup
title={t('供应商')}
<MarketFilterGroup
title={title === undefined ? t('模型厂商') : title}
items={items}
activeValue={filterVendor}
onChange={setFilterVendor}
loading={loading}
t={t}
/>
);
};
@@ -18,10 +18,10 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import PricingBentoPage from '../bento/PricingBentoPage';
import ModelMarketPage from '../market/ModelMarketPage';
const PricingPage = () => {
return <PricingBentoPage />;
return <ModelMarketPage />;
};
export default PricingPage;
@@ -1,143 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Button } from '@douyinfe/semi-ui';
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;
@@ -1,59 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import 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;
@@ -1,115 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { 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;
@@ -1,413 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { 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;
@@ -1,212 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { 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;
@@ -1,44 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { 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;
@@ -1,151 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { 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,263 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { useEffect, useMemo, useRef, useState } from 'react';
import { Alert, Button, Card } from 'antd';
import { Filter, Layers } from 'lucide-react';
import { calculateModelPrice } from '../../../../helpers';
import MarketModelCard from './MarketModelCard';
import MarketLogo from './MarketLogo';
// 供应商分区排序:优先供应商在前,其余按名称(沿用原分区规则)
const PRIORITY_VENDORS = ['OpenAI', 'Anthropic', 'Google', 'Midjourney'];
const LoadingCard = () => <Card className='mm-card mm-card-loading' loading />;
// 分区进入滚动视口(含 200px 预渲染余量)后才渲染卡片,沿用原懒渲染策略
const useInView = (rootRef) => {
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();
}
},
{ root: rootRef?.current || null, rootMargin: '200px 0px' },
);
observer.observe(el);
return () => observer.disconnect();
}, [rootRef]);
return [ref, inView];
};
const VendorSection = React.memo(
({
section,
scrollRootRef,
priceArgs,
hidePrice,
t,
copyText,
openModelDetail,
}) => {
const [sectionRef, isInView] = useInView(scrollRootRef);
const vendorIcon = section.models.find((m) => m.vendor_icon)?.vendor_icon;
return (
<section ref={sectionRef} className='mm-vendor-section'>
<div className='mm-section-title'>
{vendorIcon ? (
<MarketLogo icon={vendorIcon} size={16} />
) : (
<span className='mm-logo' aria-hidden='true'>
<Layers size={16} strokeWidth={1.65} />
</span>
)}
<h2>{section.title}</h2>
<span>{t('{{count}} 款模型', { count: section.models.length })}</span>
</div>
<div className='mm-grid'>
{isInView
? section.models.map((model, index) => (
<MarketModelCard
key={model.key || index}
model={model}
priceData={calculateModelPrice({
record: model,
...priceArgs,
})}
hidePrice={hidePrice}
t={t}
onClick={() => openModelDetail(model)}
onCopy={copyText}
/>
))
: Array.from({ length: Math.min(section.models.length, 8) }).map(
(_, i) => <LoadingCard key={i} />,
)}
</div>
</section>
);
},
);
VendorSection.displayName = 'VendorSection';
/**
* 原型 .mm-catalog:结果栏、按供应商分区的卡片网格、空态与底部说明。
* 数据、价格计算参数与回调均由页面(useModelPricingData)提供。
*/
const MarketCatalog = ({
filteredModels,
loading,
filterVendor,
discountScope,
hidePrice,
tokenUnit,
selectedGroup,
groupRatio,
groupModelDiscount,
displayPrice,
currency,
t,
copyText,
openModelDetail,
onReset,
filtersOpen,
onToggleFilters,
}) => {
const scrollRef = useRef(null);
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);
});
const sortedKeys = Object.keys(groups).sort((a, b) => {
const idxA = PRIORITY_VENDORS.indexOf(a);
const idxB = PRIORITY_VENDORS.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]);
const priceArgs = useMemo(
() => ({
selectedGroup,
groupRatio,
groupModelDiscount,
tokenUnit,
displayPrice,
currency,
}),
[
selectedGroup,
groupRatio,
groupModelDiscount,
tokenUnit,
displayPrice,
currency,
],
);
const title = filterVendor === 'all' ? t('全部模型') : filterVendor;
const total = loading ? 0 : filteredModels.length;
let body;
if (loading) {
body = (
<div className='mm-grid' aria-busy='true'>
{Array.from({ length: 8 }).map((_, i) => (
<LoadingCard key={i} />
))}
</div>
);
} else if (filteredModels.length === 0) {
body = (
<div className='mm-empty'>
<h3>{t('没有符合条件的模型')}</h3>
<p>{t('请调整搜索词或筛选条件。')}</p>
<Button onClick={onReset}>{t('重置筛选')}</Button>
</div>
);
} else {
body = (
<>
{sections.map((section) => (
<VendorSection
key={section.title}
section={section}
scrollRootRef={scrollRef}
priceArgs={priceArgs}
hidePrice={hidePrice}
t={t}
copyText={copyText}
openModelDetail={openModelDetail}
/>
))}
</>
);
}
return (
<section className='mm-catalog'>
<div className='mm-result-bar'>
<div>
<h2>{title}</h2>
<span>{t('{{count}} 款模型', { count: total })}</span>
</div>
{!hidePrice && (
<span className='mm-unit'>
{tokenUnit === 'K'
? t('价格单位 ¥ / 千 Token')
: t('价格单位 ¥ / 百万 Token')}
</span>
)}
<Button
className='mm-mobile-filter'
icon={<Filter size={16} strokeWidth={1.65} />}
aria-expanded={filtersOpen}
aria-controls='mm-filter-panel'
onClick={onToggleFilters}
>
{filtersOpen ? t('收起筛选') : t('筛选')}
</Button>
</div>
{/* 企业作用域计价口径提示:标价含企业等级折扣,个人密钥/体验中心调用仍按个人等级计费 */}
{discountScope === 'enterprise' && !hidePrice && (
<Alert
className='mm-scope-alert'
type='warning'
showIcon
message={t(
'当前为企业作用域:以下价格已按企业等级折扣展示;使用个人密钥或体验中心调用时按个人等级计费。',
)}
/>
)}
<div
ref={scrollRef}
className='mm-scroll'
tabIndex={0}
aria-label={t('模型卡片列表')}
>
{body}
{!loading && !hidePrice && (
<p className='mm-data-note'>
{t('报价按对应用户分组展示,实际费用以调用账单为准。')}
</p>
)}
</div>
</section>
);
};
export default MarketCatalog;
@@ -0,0 +1,61 @@
/*
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 'antd';
/**
* 原型 .mm-filter-group:标题 + 可换行的 Ant Design Button 组。
*
* 禁用规则沿用原 SelectableButtonGroup:item.disabled 或数值型 tagCount 为 0;
* 点击仍直接调用原筛选 setter(onChange(value)),选中态由 activeValue 决定。
* 原型按钮不显示计数;仅当 item.suffix 存在(分组倍率展示开关开启)时附加倍率文字。
*/
const MarketFilterGroup = ({ title, items = [], activeValue, onChange }) => (
<section className='mm-filter-group'>
{title && <h3>{title}</h3>}
<div>
{items.map((item) => {
const isActive = Array.isArray(activeValue)
? activeValue.includes(item.value)
: activeValue === item.value;
const isDisabled =
item.disabled ||
(typeof item.tagCount === 'number' && item.tagCount === 0);
return (
<Button
key={String(item.value)}
className={isActive ? 'mm-selected' : undefined}
aria-pressed={isActive}
disabled={isDisabled}
onClick={() => onChange(item.value)}
>
{item.icon && <span className='mm-logo'>{item.icon}</span>}
<span>{item.label}</span>
{item.suffix && (
<span className='mm-filter-ratio'>{item.suffix}</span>
)}
</Button>
);
})}
</div>
</section>
);
export default MarketFilterGroup;
@@ -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 { Button } from 'antd';
import PricingGroups from '../filter/PricingGroups';
import PricingVendors from '../filter/PricingVendors';
import PricingQuotaTypes from '../filter/PricingQuotaTypes';
import PricingTags from '../filter/PricingTags';
import PricingEndpointTypes from '../filter/PricingEndpointTypes';
/**
* 原型 .mm-sidebar:桌面常驻筛选卡;窄屏(≤600px)由结果栏「筛选」按钮展开。
* 原「更多」抽屉中的分组 / 计费类型 / 标签 / 端点筛选与吸顶栏的供应商筛选并入此处,
* 各组的选项、计数口径、禁用条件与 setter 与原实现一致。
*/
const MarketFilterSidebar = ({
open,
onReset,
t,
vendorsMap,
filterVendor,
setFilterVendor,
filterGroup,
setFilterGroup,
usableGroup,
groupRatio,
showRatio,
filterQuotaType,
setFilterQuotaType,
filterTag,
setFilterTag,
filterEndpointType,
setFilterEndpointType,
endpointMap,
allModels,
tagModels,
quotaTypeModels,
endpointTypeModels,
groupCountModels,
}) => (
<aside
id='mm-filter-panel'
className={`mm-sidebar${open ? ' mm-filters-open' : ''}`}
aria-label={t('模型筛选')}
>
<div className='mm-filter-title'>
<h2>{t('筛选')}</h2>
<Button type='text' onClick={onReset}>
{t('重置')}
</Button>
</div>
<PricingGroups
filterGroup={filterGroup}
setFilterGroup={setFilterGroup}
groupRatio={groupRatio}
usableGroup={usableGroup}
showRatio={showRatio}
t={t}
models={groupCountModels}
title={t('用户分组')}
/>
<PricingVendors
vendorsMap={vendorsMap}
filterVendor={filterVendor}
setFilterVendor={setFilterVendor}
allModels={allModels}
t={t}
/>
<PricingQuotaTypes
filterQuotaType={filterQuotaType}
setFilterQuotaType={setFilterQuotaType}
t={t}
models={quotaTypeModels}
title={t('计费类型')}
/>
<PricingTags
filterTag={filterTag}
setFilterTag={setFilterTag}
t={t}
models={tagModels}
allModels={allModels}
title={t('模型标签')}
/>
<PricingEndpointTypes
filterEndpointType={filterEndpointType}
setFilterEndpointType={setFilterEndpointType}
endpointMap={endpointMap}
t={t}
models={endpointTypeModels}
title={t('端点类型')}
/>
</aside>
);
export default MarketFilterSidebar;
@@ -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, { useCallback, useEffect, useRef, useState } from 'react';
import { Button, Input } from 'antd';
import { Search, Zap } from 'lucide-react';
import heroArt from '../../../../assets/prototype/market-hero-art.svg?raw';
/**
* 原型 .mm-hero:标题、副标题与搜索条,背景线路图取自原型 SVG(见 assets/prototype)。
*
* 搜索沿用原实现:本地值即时显示,300ms 防抖后写入 searchValue;外部值变化时同步并取消待写入。
* 「搜索」按钮 / 回车只是立即写入当前输入(与防抖到期的结果相同);「重置」调用页面传入的原重置函数。
*/
const MarketHero = ({ searchValue, setSearchValue, onReset, t }) => {
const [localSearch, setLocalSearch] = useState(searchValue);
const debounceTimer = useRef(null);
useEffect(() => {
setLocalSearch(searchValue);
if (debounceTimer.current) {
clearTimeout(debounceTimer.current);
debounceTimer.current = null;
}
}, [searchValue]);
const handleSearchChange = useCallback(
(e) => {
const value = e.target.value;
setLocalSearch(value);
if (debounceTimer.current) clearTimeout(debounceTimer.current);
debounceTimer.current = setTimeout(() => {
setSearchValue(value);
}, 300);
},
[setSearchValue],
);
const handleSubmit = (e) => {
e.preventDefault();
if (debounceTimer.current) {
clearTimeout(debounceTimer.current);
debounceTimer.current = null;
}
setSearchValue(localSearch);
};
useEffect(() => {
return () => {
if (debounceTimer.current) clearTimeout(debounceTimer.current);
};
}, []);
return (
<header className='mm-hero'>
<div className='mm-art' aria-hidden='true'>
{/* 原型静态 SVG 资源(无脚本),内联后由 market.css 控制颜色与动画 */}
<span
className='mm-art-svg'
dangerouslySetInnerHTML={{ __html: heroArt }}
/>
<div className='mm-core'>
<div />
<div />
<span>
<Zap size={30} strokeWidth={1.65} />
</span>
</div>
</div>
<div className='mm-intro'>
<h1>{t('发现适合你的 AI 模型')}</h1>
<p>{t('一站式浏览、比价与接入各大 AI 模型')}</p>
</div>
<form className='mm-search' role='search' onSubmit={handleSubmit}>
<Input
allowClear
prefix={<Search size={18} strokeWidth={1.65} />}
aria-label={t('搜索模型名称')}
placeholder={t('搜索模型名称,例如 gpt、claude')}
value={localSearch}
onChange={handleSearchChange}
/>
<Button onClick={onReset}>{t('重置')}</Button>
<Button
type='primary'
htmlType='submit'
icon={<Search size={16} strokeWidth={1.65} />}
>
{t('搜索')}
</Button>
</form>
</header>
);
};
export default MarketHero;
@@ -18,19 +18,23 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Button } from '@douyinfe/semi-ui';
import { Avatar } from 'antd';
import { getLobeHubIcon } from '../../../../helpers';
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>
);
};
/**
* 原型 .mm-logo 图标框:优先模型图标,其次供应商图标,最后回退为模型名前两位。
* 图标来源与原卡片 / 详情头部的判定顺序一致。
*/
const MarketLogo = ({ icon, fallbackText, size = 20, className = '' }) => (
<span className={`mm-logo ${className}`.trim()} aria-hidden='true'>
{icon ? (
getLobeHubIcon(icon, size)
) : (
<Avatar size={size} shape='square'>
{(fallbackText || 'AI').slice(0, 2).toUpperCase()}
</Avatar>
)}
</span>
);
export default FilterModalFooter;
export default MarketLogo;
@@ -0,0 +1,207 @@
/*
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, Card, Tag, Tooltip } from 'antd';
import { Copy, Lock } from 'lucide-react';
import { getDiscountBadgeText } from '../../../../helpers';
import MarketLogo from './MarketLogo';
/** 计费类型文案:与详情「分组价格」的判定顺序一致 */
export const getBillingLabel = (priceData, t) => {
if (priceData?.isPerSecond) return t('按秒计费');
if (priceData?.isPerImageResolution) return t('按分辨率计费');
if (priceData?.isPerToken) return t('按量计费');
return t('按次计费');
};
/**
* 把 calculateModelPrice 的结果整理为原型卡片的价格格:主价格(含官方价删除线)与附加价格行。
* 只做展示映射,不重新计算价格。
*/
const buildCardPrices = (priceData, t) => {
if (priceData.isPerToken) {
return {
tier: false,
main: [
{
key: 'input',
label: t('输入'),
value: priceData.inputPrice,
official: priceData.official?.inputPrice,
},
{
key: 'output',
label: t('输出'),
value: priceData.completionPrice,
official: priceData.official?.completionPrice,
},
],
extras: (priceData.extraPrices || []).map((item) => ({
key: item.key,
label: t(item.labelKey),
value: item.price,
})),
};
}
if (priceData.isPerSecond || priceData.isPerImageResolution) {
const tiers = priceData.isPerSecond
? priceData.videoTiers || []
: priceData.imageTiers || [];
const unit = priceData.isPerSecond ? t('秒') : t('张');
return {
tier: true,
main: tiers.length
? tiers.map((tier) => ({
key: tier.key,
label: `${tier.label} / ${unit}`,
value: tier.price,
}))
: [{ key: 'none', label: getBillingLabel(priceData, t), value: '-' }],
note: getBillingLabel(priceData, t),
};
}
return {
tier: false,
main: [
{
key: 'price',
label: `${t('单价')} / ${t('次')}`,
value: priceData.price,
official: priceData.official?.price,
},
],
note: getBillingLabel(priceData, t),
};
};
const trackPointer = (e) => {
const rect = e.currentTarget.getBoundingClientRect();
e.currentTarget.style.setProperty(
'--pointer-x',
`${e.clientX - rect.left}px`,
);
e.currentTarget.style.setProperty('--pointer-y', `${e.clientY - rect.top}px`);
};
const MarketModelCard = ({
model,
priceData,
hidePrice,
onClick,
onCopy,
t,
}) => {
const discountText = getDiscountBadgeText(priceData);
const prices = hidePrice ? null : buildCardPrices(priceData, t);
const handleKeyDown = (e) => {
if (e.target !== e.currentTarget) return;
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
onClick();
}
};
return (
<Card
className='mm-card'
role='button'
tabIndex={0}
aria-label={t('查看 {{name}} 详情', { name: model.model_name })}
onClick={onClick}
onKeyDown={handleKeyDown}
onPointerMove={trackPointer}
>
<div className='mm-card-head'>
<MarketLogo
icon={model.icon || model.vendor_icon}
fallbackText={model.model_name}
/>
<h3 title={model.model_name}>{model.model_name}</h3>
{model.level_locked && (
<Tooltip title={t('当前等级无权调用此模型,升级等级后可用')}>
<Tag icon={<Lock size={11} />} bordered={false}>
{t('仅可见')}
</Tag>
</Tooltip>
)}
<Tooltip title={t('复制模型名称')}>
<Button
type='text'
aria-label={t('复制模型名称')}
icon={<Copy size={16} strokeWidth={1.65} />}
onClick={(e) => {
e.stopPropagation();
onCopy(model.model_name);
}}
/>
</Tooltip>
</div>
{prices && (
<>
<div className={`mm-prices${prices.tier ? ' mm-tier-prices' : ''}`}>
{prices.main.map((item) => (
<div key={item.key}>
<span>{item.label}</span>
<strong>{item.value}</strong>
{item.official && <del>{item.official}</del>}
</div>
))}
</div>
<div className='mm-cache'>
{prices.extras?.map((item) => (
<span key={item.key}>
{item.label} <b>{item.value}</b>
</span>
))}
{prices.note && <span>{prices.note}</span>}
</div>
<div className='mm-card-foot'>
{priceData?.usedGroup ? (
<span
title={t('该价格按 {{group}} 分组倍率计算', {
group: priceData.usedGroup,
})}
>
{priceData.usedGroup}
</span>
) : (
<span />
)}
{discountText ? (
<Tooltip
title={t(
'相比官方牌价的折扣,按当前计价分组实付价计算(已含您的等级折扣),仅供参考',
)}
>
<Tag bordered={false}>{discountText}</Tag>
</Tooltip>
) : (
<span>{getBillingLabel(priceData, t)}</span>
)}
</div>
</>
)}
</Card>
);
};
export default React.memo(MarketModelCard);
@@ -0,0 +1,200 @@
/*
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 } from 'react';
import { Image } from 'antd';
import { useModelPricingData } from '../../../../hooks/model-pricing/useModelPricingData';
import { usePricingFilterCounts } from '../../../../hooks/model-pricing/usePricingFilterCounts';
import { resetPricingFilters } from '../../../../helpers/utils';
import MarketHero from './MarketHero';
import MarketFilterSidebar from './MarketFilterSidebar';
import MarketCatalog from './MarketCatalog';
import ModelDetailSideSheet from '../modal/ModelDetailSideSheet';
import { useMarketThemeStyle } from './marketTheme';
import './market.css';
/**
* 模型超市(/market)页面:按原型 .mm-page 布局组合 Hero 搜索、筛选侧栏、模型目录与详情抽屉。
* 数据、筛选状态、价格计算、复制与详情开关全部来自原有 useModelPricingData / usePricingFilterCounts,
* 本组件只负责视图编排。
*/
const ModelMarketPage = () => {
const pricingData = useModelPricingData();
// 原「更多」抽屉的开关状态,现用于窄屏筛选面板展开 / 收起
const [showSettings, setShowSettings] = useState(false);
const themeStyle = useMarketThemeStyle();
const {
searchValue,
setSearchValue,
handleChange,
filterVendor,
setFilterVendor,
filteredModels,
loading,
selectedGroup,
groupRatio,
groupModelDiscount,
discountScope,
tokenUnit,
displayPrice,
currency,
showRatio,
hidePrice,
t,
copyText,
openModelDetail,
filterTag,
setFilterTag,
filterQuotaType,
setFilterQuotaType,
filterEndpointType,
setFilterEndpointType,
filterGroup,
setFilterGroup,
setCurrentPage,
autoGroups,
endpointMap,
vendorsMap,
showModelDetail,
closeModelDetail,
selectedModel,
usableGroup,
modalImageUrl,
isModalOpenurl,
setIsModalOpenurl,
models,
} = pricingData;
const { quotaTypeModels, endpointTypeModels, tagModels, groupCountModels } =
usePricingFilterCounts({
models,
filterGroup,
filterQuotaType,
filterEndpointType,
filterVendor,
filterTag,
searchValue,
});
// 复用原侧栏的 resetPricingFilters:清空搜索词与五类筛选。
// 不传货币 / 单位 / 视图 setter,避免改动页面既有的计价展示口径。
const handleReset = () =>
resetPricingFilters({
handleChange,
setFilterGroup,
setFilterQuotaType,
setFilterEndpointType,
setFilterVendor,
setFilterTag,
setCurrentPage,
});
return (
<div className='mm-page mm-theme' style={themeStyle}>
<MarketHero
searchValue={searchValue}
setSearchValue={setSearchValue}
onReset={handleReset}
t={t}
/>
<div className='mm-workspace'>
<MarketFilterSidebar
open={showSettings}
onReset={handleReset}
t={t}
vendorsMap={vendorsMap}
filterVendor={filterVendor}
setFilterVendor={setFilterVendor}
filterGroup={filterGroup}
setFilterGroup={setFilterGroup}
usableGroup={usableGroup}
groupRatio={groupRatio}
showRatio={showRatio}
filterQuotaType={filterQuotaType}
setFilterQuotaType={setFilterQuotaType}
filterTag={filterTag}
setFilterTag={setFilterTag}
filterEndpointType={filterEndpointType}
setFilterEndpointType={setFilterEndpointType}
endpointMap={endpointMap}
allModels={models}
tagModels={tagModels}
quotaTypeModels={quotaTypeModels}
endpointTypeModels={endpointTypeModels}
groupCountModels={groupCountModels}
/>
<MarketCatalog
filteredModels={filteredModels}
loading={loading}
filterVendor={filterVendor}
discountScope={discountScope}
hidePrice={hidePrice}
tokenUnit={tokenUnit}
selectedGroup={selectedGroup}
groupRatio={groupRatio}
groupModelDiscount={groupModelDiscount}
displayPrice={displayPrice}
currency={currency}
t={t}
copyText={copyText}
openModelDetail={openModelDetail}
onReset={handleReset}
filtersOpen={showSettings}
onToggleFilters={() => setShowSettings((open) => !open)}
/>
</div>
<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}
/>
{/* 原图片预览状态(modalImageUrl / isModalOpenurl)保留,改用 Ant Design Image 受控预览 */}
{modalImageUrl && (
<Image
className='hidden'
src={modalImageUrl}
preview={{
visible: isModalOpenurl,
src: modalImageUrl,
onVisibleChange: (visible) => setIsModalOpenurl(visible),
}}
/>
)}
</div>
);
};
export default ModelMarketPage;
File diff suppressed because it is too large Load Diff
@@ -17,16 +17,18 @@ 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';
import { theme } from 'antd';
const PricingView = ({ viewMode = 'table', ...props }) => {
return viewMode === 'card' ? (
<PricingCardView {...props} />
) : (
<PricingTable {...props} />
);
/**
* 模型超市局部 CSS 变量桥:主色、正文、分隔线取自当前 ConfigProvider token,
* 原型独有的色值(Hero 渐变、浅金底等)在 market.css 的 `--mm-*` 中按原型实测定义。
* 页面根节点与详情抽屉(Portal)都挂 `.mm-theme` 并使用同一份变量。
*/
export const useMarketThemeStyle = () => {
const { token } = theme.useToken();
return {
'--mm-brand': token.colorPrimary,
'--mm-text': token.colorText,
'--mm-border': token.colorBorderSecondary,
};
};
export default PricingView;
@@ -18,17 +18,19 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Modal, Typography, Button, Spin } from '@douyinfe/semi-ui';
import { X, Bot } from 'lucide-react';
import { Button, Drawer, Spin } from 'antd';
import { useIsMobile } from '../../../../hooks/common/useIsMobile';
import { useMarketThemeStyle } from '../market/marketTheme';
import ModelHeader from './components/ModelHeader';
import ModelBasicInfo from './components/ModelBasicInfo';
import ModelEndpoints from './components/ModelEndpoints';
import ModelPricingTable from './components/ModelPricingTable';
const { Text } = Typography;
/**
* 模型详情:原型为右侧 820px Drawer(窄屏铺满)。
* 打开条件、关闭回调(遮罩 / Esc / 关闭按钮均走 onClose)与内容数据源保持原实现。
*/
const ModelDetailSideSheet = ({
visible,
onClose,
@@ -47,134 +49,55 @@ const ModelDetailSideSheet = ({
t,
}) => {
const isMobile = useIsMobile();
const themeStyle = useMarketThemeStyle();
return (
<Modal
title={null}
header={null}
footer={null}
bodyStyle={{
padding: '0',
borderRadius: '20px',
overflow: 'hidden',
}}
className='model-detail-modal'
visible={visible}
width={isMobile ? '95%' : 560}
centered
closeIcon={null}
onCancel={onClose}
maskClosable={true}
maskStyle={{
backgroundColor: 'rgba(0, 0, 0, 0.4)',
backdropFilter: 'blur(8px)',
}}
<Drawer
title={t('模型详情')}
open={visible}
onClose={onClose}
width={isMobile ? '100%' : 820}
rootClassName='mm-detail-drawer mm-theme'
rootStyle={themeStyle}
footer={
<div className='mm-detail-footer'>
<Button type='primary' onClick={onClose}>
{t('关闭')}
</Button>
</div>
}
>
{/* 自定义头部 */}
<div className='px-4 pt-4 pb-3'>
<div className='flex items-center justify-between'>
<div className='flex items-center gap-2'>
<div className='p-1.5 bg-gradient-to-br from-brand-from to-brand-to rounded-lg'>
<Bot size={16} className='text-white' />
</div>
<div>
<h2 className='text-sm font-semibold text-gray-800 dark:text-gray-100'>
{t('模型详情')}
</h2>
<p className='text-[11px] text-gray-500 dark:text-gray-400'>
{t('查看模型定价与配置信息')}
</p>
</div>
</div>
{/* 关闭按钮 */}
<button
onClick={onClose}
className='p-1.5 rounded-lg bg-gray-100 hover:bg-gray-200 dark:bg-neutral-800 dark:hover:bg-neutral-700 transition-colors'
>
<X size={16} className='text-gray-500 dark:text-gray-400' />
</button>
{!modelData ? (
<div className='mm-detail-loading'>
<Spin size='large' />
<span>{t('加载中...')}</span>
</div>
{/* 模型标题 */}
{modelData && (
<div className='mt-2'>
<ModelHeader modelData={modelData} vendorsMap={vendorsMap} t={t} />
</div>
)}
</div>
{/* 内容区域 */}
<div
className='overflow-y-auto'
style={{
maxHeight: isMobile ? 'calc(85vh - 180px)' : 'calc(75vh - 160px)',
}}
>
<div className='px-4 pb-3'>
{!modelData ? (
<div className='flex flex-col justify-center items-center py-12'>
<Spin size='large' />
<Text type='secondary' className='mt-3'>
{t('加载中...')}
</Text>
</div>
) : (
/* 分区平铺 + 发丝分隔线:原先每区一层白卡边框,与弹窗自身、
* 区内表格边框叠出三层线框(用户反馈嵌套过多),改为零嵌套 */
<div className='divide-y divide-gray-100 dark:divide-neutral-800'>
{/* 基本信息 */}
<div className='py-3 first:pt-1'>
<ModelBasicInfo
modelData={modelData}
vendorsMap={vendorsMap}
t={t}
/>
</div>
{/* 端点信息 */}
<div className='py-3'>
<ModelEndpoints
modelData={modelData}
endpointMap={endpointMap}
t={t}
/>
</div>
{/* 定价表格 */}
{!hidePrice && (
<div className='py-3'>
<ModelPricingTable
modelData={modelData}
groupRatio={groupRatio}
groupModelDiscount={groupModelDiscount}
currency={currency}
tokenUnit={tokenUnit}
displayPrice={displayPrice}
showRatio={showRatio}
usableGroup={usableGroup}
autoGroups={autoGroups}
t={t}
/>
</div>
)}
</div>
) : (
<>
<ModelHeader modelData={modelData} vendorsMap={vendorsMap} t={t} />
<ModelBasicInfo modelData={modelData} vendorsMap={vendorsMap} t={t} />
<ModelEndpoints
modelData={modelData}
endpointMap={endpointMap}
t={t}
/>
{!hidePrice && (
<ModelPricingTable
modelData={modelData}
groupRatio={groupRatio}
groupModelDiscount={groupModelDiscount}
currency={currency}
tokenUnit={tokenUnit}
displayPrice={displayPrice}
showRatio={showRatio}
usableGroup={usableGroup}
autoGroups={autoGroups}
t={t}
/>
)}
</div>
</div>
{/* 底部按钮 */}
<div className='px-4 pb-4 pt-2'>
<Button
block
theme='solid'
onClick={onClose}
className='!bg-gradient-to-r !from-brand-from !to-brand-to hover:!from-brand-from hover:!to-brand-to !rounded-xl !h-10 !font-medium !shadow-md !shadow-brand/20 transition-all'
>
{t('关闭')}
</Button>
</div>
</Modal>
</>
)}
</Drawer>
);
};
@@ -1,68 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Modal } from '@douyinfe/semi-ui';
import { resetPricingFilters } from '../../../../helpers/utils';
import FilterModalContent from './components/FilterModalContent';
import FilterModalFooter from './components/FilterModalFooter';
const PricingFilterModal = ({ visible, onClose, sidebarProps, t }) => {
const handleResetFilters = () =>
resetPricingFilters({
handleChange: sidebarProps.handleChange,
setShowWithRecharge: sidebarProps.setShowWithRecharge,
setCurrency: sidebarProps.setCurrency,
setViewMode: sidebarProps.setViewMode,
setFilterGroup: sidebarProps.setFilterGroup,
setFilterQuotaType: sidebarProps.setFilterQuotaType,
setFilterEndpointType: sidebarProps.setFilterEndpointType,
setFilterVendor: sidebarProps.setFilterVendor,
setFilterTag: sidebarProps.setFilterTag,
setCurrentPage: sidebarProps.setCurrentPage,
setTokenUnit: sidebarProps.setTokenUnit,
});
const footer = (
<FilterModalFooter onReset={handleResetFilters} onConfirm={onClose} t={t} />
);
return (
<Modal
title={t('筛选')}
visible={visible}
onCancel={onClose}
footer={footer}
className='pricing-filter-modal'
style={{ width: '100%', height: '100%', margin: 0 }}
bodyStyle={{
padding: 0,
height: 'calc(100vh - 160px)',
overflowY: 'auto',
scrollbarWidth: 'none',
msOverflowStyle: 'none',
backgroundColor: 'var(--semi-color-bg-0)',
}}
>
<FilterModalContent sidebarProps={sidebarProps} t={t} />
</Modal>
);
};
export default PricingFilterModal;
@@ -1,137 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import PricingDisplaySettings from '../../filter/PricingDisplaySettings';
import PricingGroups from '../../filter/PricingGroups';
import PricingQuotaTypes from '../../filter/PricingQuotaTypes';
import PricingEndpointTypes from '../../filter/PricingEndpointTypes';
import PricingVendors from '../../filter/PricingVendors';
import PricingTags from '../../filter/PricingTags';
import { usePricingFilterCounts } from '../../../../../hooks/model-pricing/usePricingFilterCounts';
const FilterModalContent = ({ sidebarProps, t }) => {
const {
showWithRecharge,
setShowWithRecharge,
currency,
setCurrency,
handleChange,
setActiveKey,
showRatio,
viewMode,
setViewMode,
filterGroup,
setFilterGroup,
filterQuotaType,
setFilterQuotaType,
filterEndpointType,
setFilterEndpointType,
filterVendor,
setFilterVendor,
filterTag,
setFilterTag,
tokenUnit,
setTokenUnit,
loading,
...categoryProps
} = sidebarProps;
const {
quotaTypeModels,
endpointTypeModels,
vendorModels,
tagModels,
groupCountModels,
} = usePricingFilterCounts({
models: categoryProps.models,
filterGroup,
filterQuotaType,
filterEndpointType,
filterVendor,
filterTag,
searchValue: sidebarProps.searchValue,
});
return (
<>
<PricingDisplaySettings
showWithRecharge={showWithRecharge}
setShowWithRecharge={setShowWithRecharge}
currency={currency}
setCurrency={setCurrency}
showRatio={showRatio}
viewMode={viewMode}
setViewMode={setViewMode}
tokenUnit={tokenUnit}
setTokenUnit={setTokenUnit}
loading={loading}
t={t}
/>
<PricingVendors
filterVendor={filterVendor}
setFilterVendor={setFilterVendor}
models={vendorModels}
allModels={categoryProps.models}
loading={loading}
t={t}
/>
<PricingTags
filterTag={filterTag}
setFilterTag={setFilterTag}
models={tagModels}
allModels={categoryProps.models}
loading={loading}
t={t}
/>
<PricingGroups
filterGroup={filterGroup}
setFilterGroup={setFilterGroup}
usableGroup={categoryProps.usableGroup}
groupRatio={categoryProps.groupRatio}
models={groupCountModels}
loading={loading}
showRatio={showRatio}
t={t}
/>
<PricingQuotaTypes
filterQuotaType={filterQuotaType}
setFilterQuotaType={setFilterQuotaType}
models={quotaTypeModels}
loading={loading}
t={t}
/>
<PricingEndpointTypes
filterEndpointType={filterEndpointType}
setFilterEndpointType={setFilterEndpointType}
models={endpointTypeModels}
allModels={categoryProps.models}
loading={loading}
t={t}
/>
</>
);
};
export default FilterModalContent;
@@ -18,11 +18,13 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { FileText, Sparkles } from 'lucide-react';
import { stringToColor } from '../../../../../helpers';
import { Tag } from 'antd';
const ModelBasicInfo = ({ modelData, vendorsMap = {}, t }) => {
// 获取模型描述
/**
* 详情「基本信息」:描述取值顺序(模型描述 → 供应商信息 → 暂无)与标签拆分规则沿用原实现。
* 原型未定义标签样式,使用 Ant Design 默认 Tag。
*/
const ModelBasicInfo = ({ modelData, t }) => {
const getModelDescription = () => {
if (!modelData) return t('暂无模型描述');
if (modelData.description) return modelData.description;
@@ -31,59 +33,25 @@ const ModelBasicInfo = ({ modelData, vendorsMap = {}, t }) => {
return t('暂无模型描述');
};
// 获取模型标签
const getModelTags = () => {
const tags = [];
if (modelData?.tags) {
const customTags = modelData.tags.split(',').filter((tag) => tag.trim());
customTags.forEach((tag) => {
const tagText = tag.trim();
tags.push({ text: tagText, color: stringToColor(tagText) });
});
}
return tags;
};
const tags = getModelTags();
const tags = modelData?.tags
? modelData.tags
.split(',')
.map((tag) => tag.trim())
.filter(Boolean)
: [];
return (
<div className='space-y-3'>
{/* 标题行 —— 单行紧凑小节头(原大色块 chip+副标题在弹窗内层级过重) */}
<h3 className='flex items-center gap-1.5 text-[13px] font-semibold text-gray-900 dark:text-white'>
<FileText
size={14}
className='text-brand-deep dark:text-brand-from flex-shrink-0'
/>
{t('基本信息')}
</h3>
{/* 描述区域 */}
<div className='relative pl-3'>
<div className='absolute left-0 top-0 bottom-0 w-0.5 rounded-full bg-brand-from' />
<p className='text-sm text-gray-600 dark:text-gray-300 leading-relaxed'>
{getModelDescription()}
</p>
</div>
{/* 标签区域 */}
<section className='mm-detail-section'>
<h3>{t('基本信息')}</h3>
<p className='mm-detail-description'>{getModelDescription()}</p>
{tags.length > 0 && (
<div className='flex flex-wrap gap-1.5'>
<div className='mm-detail-tags'>
{tags.map((tag, index) => (
<span
key={index}
className='inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium'
style={{
backgroundColor: `${tag.color}15`,
color: tag.color,
}}
>
<Sparkles size={10} />
{tag.text}
</span>
<Tag key={`${tag}-${index}`}>{tag}</Tag>
))}
</div>
)}
</div>
</section>
);
};
@@ -18,8 +18,11 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Plug, Zap, ArrowRight, Globe } from 'lucide-react';
import { Empty, Tag } from 'antd';
/**
* 详情「API 端点」:端点路径中的 {model} 替换与默认 POST 方法沿用原实现。
*/
const ModelEndpoints = ({ modelData, endpointMap = {}, t }) => {
const types = modelData?.supported_endpoint_types || [];
@@ -33,96 +36,33 @@ const ModelEndpoints = ({ modelData, endpointMap = {}, t }) => {
return { path, method: info.method || 'POST' };
};
const getMethodColor = (method) => {
const colors = {
GET: {
bg: 'bg-emerald-500/10',
text: 'text-emerald-600 dark:text-emerald-400',
border: 'border-emerald-500/20',
},
POST: {
bg: 'bg-blue-500/10',
text: 'text-blue-600 dark:text-blue-400',
border: 'border-blue-500/20',
},
PUT: {
bg: 'bg-amber-500/10',
text: 'text-amber-600 dark:text-amber-400',
border: 'border-amber-500/20',
},
DELETE: {
bg: 'bg-red-500/10',
text: 'text-red-600 dark:text-red-400',
border: 'border-red-500/20',
},
};
return colors[method] || colors.POST;
};
return (
<div className='space-y-3'>
{/* 标题区域 —— 单行紧凑小节头 */}
<div className='flex items-center justify-between'>
<h3 className='flex items-center gap-1.5 text-[13px] font-semibold text-gray-900 dark:text-white'>
<Plug
size={14}
className='text-brand-deep dark:text-brand-from flex-shrink-0'
/>
{t('API端点')}
</h3>
<span className='text-xs text-gray-500 dark:text-gray-400 font-medium'>
<Globe size={12} className='inline mr-1' />
<section className='mm-detail-section'>
<div className='mm-detail-section-head'>
<h3>{t('API 端点')}</h3>
<span>
{types.length} {t('个端点')}
</span>
</div>
{/* 端点列表 */}
<div className='space-y-2'>
{types.map((type) => {
const { path, method } = getEndpointInfo(type);
const methodStyle = getMethodColor(method);
return (
<div
key={type}
className='flex items-center justify-between gap-3 py-2'
>
<div className='flex-1 min-w-0'>
<div className='flex items-center gap-2'>
<Zap size={12} className='text-brand flex-shrink-0' />
<span className='text-sm font-medium text-gray-900 dark:text-white'>
{type}
</span>
</div>
{path && (
<div className='flex items-center gap-1.5 text-xs text-gray-500 dark:text-gray-400 mt-0.5 ml-5'>
<ArrowRight size={10} className='flex-shrink-0' />
<code className='font-mono text-gray-600 dark:text-gray-300'>
{path}
</code>
</div>
)}
</div>
{path && (
<span
className={`flex-shrink-0 px-2 py-0.5 rounded text-xs font-semibold ${methodStyle.bg} ${methodStyle.text}`}
>
{method}
</span>
)}
{types.map((type) => {
const { path, method } = getEndpointInfo(type);
return (
<div key={type} className='mm-detail-endpoint'>
<div>
<strong>{type}</strong>
{path && <code>{path}</code>}
</div>
);
})}
</div>
{path && <Tag bordered={false}>{method}</Tag>}
</div>
);
})}
{types.length === 0 && (
<div className='text-center py-6 text-gray-400 dark:text-gray-500'>
<Plug size={24} className='mx-auto mb-2 opacity-50' />
<p className='text-sm'>{t('暂无端点信息')}</p>
</div>
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={t('暂无端点信息')}
/>
)}
</div>
</section>
);
};
@@ -18,79 +18,34 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { Typography, Toast, Avatar } from '@douyinfe/semi-ui';
import { getLobeHubIcon } from '../../../../../helpers';
import { Typography } from 'antd';
import { Copy } from 'lucide-react';
import { showSuccess } from '../../../../../helpers';
import MarketLogo from '../../market/MarketLogo';
const { Paragraph } = Typography;
const CARD_STYLES = {
container:
'w-12 h-12 rounded-2xl flex items-center justify-center relative shadow-md',
icon: 'w-8 h-8 flex items-center justify-center',
};
const ModelHeader = ({ modelData, vendorsMap = {}, t }) => {
// 获取模型图标(优先模型图标,其次供应商图标)
const getModelIcon = () => {
// 1) 优先使用模型自定义图标
if (modelData?.icon) {
return (
<div className={CARD_STYLES.container}>
<div className={CARD_STYLES.icon}>
{getLobeHubIcon(modelData.icon, 32)}
</div>
</div>
);
}
// 2) 退化为供应商图标
if (modelData?.vendor_icon) {
return (
<div className={CARD_STYLES.container}>
<div className={CARD_STYLES.icon}>
{getLobeHubIcon(modelData.vendor_icon, 32)}
</div>
</div>
);
}
// 如果没有供应商图标,使用模型名称的前两个字符
const avatarText = modelData?.model_name?.slice(0, 2).toUpperCase() || 'AI';
return (
<div className={CARD_STYLES.container}>
<Avatar
size='large'
style={{
width: 48,
height: 48,
borderRadius: 16,
fontSize: 16,
fontWeight: 'bold',
}}
>
{avatarText}
</Avatar>
</div>
);
};
return (
<div className='flex items-center'>
{getModelIcon()}
<div className='ml-3 font-normal'>
<Paragraph
className='!mb-0 !text-lg !font-medium'
copyable={{
content: modelData?.model_name || '',
onCopy: () => Toast.success({ content: t('已复制模型名称') }),
}}
>
<span className='truncate max-w-60 font-bold'>
{modelData?.model_name || t('未知模型')}
</span>
</Paragraph>
</div>
</div>
);
};
/**
* 详情头部:模型图标(优先模型图标,其次供应商图标,最后名称缩写)+ 名称 + 复制。
* 复制沿用 Typography copyable 与原「已复制模型名称」成功提示。
*/
const ModelHeader = ({ modelData, t }) => (
<div className='mm-detail-model'>
<MarketLogo
icon={modelData?.icon || modelData?.vendor_icon}
fallbackText={modelData?.model_name}
size={26}
/>
<Typography.Title
level={2}
copyable={{
text: modelData?.model_name || '',
icon: <Copy size={16} strokeWidth={1.65} />,
tooltips: [t('复制模型名称'), t('已复制模型名称')],
onCopy: () => showSuccess(t('已复制模型名称')),
}}
>
{modelData?.model_name || t('未知模型')}
</Typography.Title>
</div>
);
export default ModelHeader;
@@ -18,19 +18,18 @@ For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import {
Coins,
ChevronRight,
Layers,
Calculator,
BadgePercent,
} from 'lucide-react';
import { Empty, Table, Tag, Tooltip } from 'antd';
import { ChevronRight } from 'lucide-react';
import {
calculateModelPrice,
formatOfficialPriceDisplay,
getDiscountBadgeText,
} from '../../../../../helpers';
/**
* 详情「分组价格」:原型为 Ant Design Table(small)。
* 可用分组、auto 链路、官方价参考行、各计费类型的列与价格计算全部沿用原实现,仅改为 Table 呈现。
*/
const ModelPricingTable = ({
modelData,
groupRatio,
@@ -38,7 +37,6 @@ const ModelPricingTable = ({
currency,
tokenUnit,
displayPrice,
showRatio,
usableGroup,
autoGroups = [],
t,
@@ -96,262 +94,173 @@ const ModelPricingTable = ({
const extraPriceColumns = Array.isArray(samplePriceData?.extraPrices)
? samplePriceData.extraPrices
: [];
// 按秒分档:列 = 各档位,由配置顺序决定
const videoTierColumns = isPerSecond
// 按秒 / 按分辨率分档:列 = 各档位,由配置顺序决定
const tierColumns = isPerSecond
? (modelData?.video_second_pricing?.tiers || []).map((tier) => ({
key: tier.key,
label: tier.label || tier.key,
}))
: [];
const imageTierColumns = isPerImageResolution
? (modelData?.image_resolution_pricing?.tiers || []).map((tier) => ({
key: tier.key,
label: tier.label || tier.key,
}))
: [];
const tierColumns = isPerSecond ? videoTierColumns : imageTierColumns;
: isPerImageResolution
? (modelData?.image_resolution_pricing?.tiers || []).map((tier) => ({
key: tier.key,
label: tier.label || tier.key,
}))
: [];
const isTierPricing = isPerSecond || isPerImageResolution;
const priceGridStyle = isTierPricing
? {
gridTemplateColumns: `minmax(76px, 1fr) repeat(${Math.max(tierColumns.length, 1)}, minmax(88px, max-content))`,
minWidth:
tierColumns.length > 0
? `${160 + tierColumns.length * 100}px`
: undefined,
}
: isPerToken
? {
gridTemplateColumns: `minmax(76px, 1fr) repeat(${2 + extraPriceColumns.length}, minmax(88px, max-content))`,
minWidth:
extraPriceColumns.length > 0
? `${260 + extraPriceColumns.length * 108}px`
: undefined,
}
: undefined;
const price = (value, extra = false) => (
<span className={`mm-detail-price${extra ? ' mm-detail-price-extra' : ''}`}>
{value || '-'}
</span>
);
const official = (value) => <del className='mm-official'>{value || '-'}</del>;
const groupColumn = {
title: t('分组'),
dataIndex: 'group',
key: 'group',
width: 180,
render: (_, row) =>
row.official ? (
<span
className='mm-detail-group mm-official'
title={t('管理员维护的模型原厂牌价,未含分组倍率,仅供对照')}
>
{t('官方价')}
</span>
) : (
<span className='mm-detail-group'>
{row.group}
{row.discountText && (
<Tooltip
title={t(
'相比官方牌价的折扣,按当前计价分组实付价计算(已含您的等级折扣),仅供参考',
)}
>
<Tag bordered={false}>{row.discountText}</Tag>
</Tooltip>
)}
</span>
),
};
let priceColumns;
if (isTierPricing) {
const unit = isPerSecond ? t('秒') : t('张');
priceColumns = tierColumns.map((col) => ({
title: `${col.label} / ${unit}`,
key: col.key,
align: 'right',
width: 135,
render: (_, row) => {
const tiers = isPerSecond
? row.priceData.videoTiers
: row.priceData.imageTiers;
return price(tiers?.find((tier) => tier.key === col.key)?.price);
},
}));
} else if (isPerToken) {
priceColumns = [
{
title: `${t('输入价格')} / ${tokenLabel}`,
key: 'input',
align: 'right',
width: 135,
render: (_, row) =>
row.official
? official(officialDisplay.input)
: price(row.priceData.inputPrice),
},
{
title: `${t('输出价格')} / ${tokenLabel}`,
key: 'output',
align: 'right',
width: 135,
render: (_, row) =>
row.official
? official(officialDisplay.output)
: price(row.priceData.completionPrice || row.priceData.outputPrice),
},
...extraPriceColumns.map((column) => ({
title: `${t(column.labelKey)} / ${tokenLabel}`,
key: column.key,
align: 'right',
width: 135,
render: (_, row) =>
row.official
? official(null)
: price(
row.priceData.extraPrices?.find(
(extra) => extra.key === column.key,
)?.price,
true,
),
})),
];
} else {
priceColumns = [
{
title: `${t('单价')} / ${t('次')}`,
key: 'price',
align: 'right',
width: 135,
render: (_, row) =>
row.official
? official(officialDisplay.perCall)
: price(row.priceData.price),
},
];
}
const dataSource = [
...(officialDisplay && !isTierPricing
? [{ key: '__official__', official: true }]
: []),
...availableGroups.map((group, idx) => ({
key: group,
group,
priceData: groupPriceDataList[idx],
discountText: getDiscountBadgeText(groupPriceDataList[idx]),
})),
];
return (
<div className='space-y-3'>
{/* 标题区域 —— 单行紧凑小节头 */}
<div className='flex items-center justify-between'>
<h3 className='flex items-center gap-1.5 text-[13px] font-semibold text-gray-900 dark:text-white'>
<Coins
size={14}
className='text-brand-deep dark:text-brand-from flex-shrink-0'
/>
{t('分组价格')}
</h3>
<span className='text-xs text-gray-500 dark:text-gray-400 font-medium'>
<Calculator size={12} className='inline mr-1' />
{billingLabel}
</span>
<section className='mm-detail-section'>
<div className='mm-detail-section-head'>
<h3>{t('分组价格')}</h3>
<span>{billingLabel}</span>
</div>
{/* Auto分组链路 */}
{autoChain.length > 0 && (
<div className='flex items-center flex-wrap gap-1.5 text-xs text-gray-500 dark:text-gray-400'>
<Layers size={12} className='text-brand' />
<div className='mm-detail-auto'>
<span>{t('auto分组调用链路')}</span>
{autoChain.map((g, idx) => (
<React.Fragment key={g}>
<span className='px-1.5 py-0.5 rounded text-brand-deep dark:text-brand-from font-medium bg-brand/10'>
{g}
</span>
{idx < autoChain.length - 1 && (
<ChevronRight size={10} className='text-gray-400' />
)}
<Tag bordered={false}>{g}</Tag>
{idx < autoChain.length - 1 && <ChevronRight size={12} />}
</React.Fragment>
))}
</div>
)}
{/* 价格表格 */}
<div className='overflow-x-auto'>
{/* 表头 */}
<div
className={`grid ${isPerToken || isTierPricing ? '' : 'grid-cols-2'} text-[11px] font-medium text-gray-400 dark:text-gray-400 border-b border-gray-100 dark:border-neutral-700 pb-2 mb-1`}
style={priceGridStyle}
>
<div>{t('分组')}</div>
{isPerSecond ? (
videoTierColumns.map((col) => (
<div key={col.key} className='text-right'>
{col.label} / {t('秒')}
</div>
))
) : isPerImageResolution ? (
imageTierColumns.map((col) => (
<div key={col.key} className='text-right'>
{col.label} / {t('张')}
</div>
))
) : isPerToken ? (
<>
<div className='text-right'>
{t('输入价格')} / {tokenLabel}
</div>
<div className='text-right'>
{t('输出价格')} / {tokenLabel}
</div>
{extraPriceColumns.map((item) => (
<div key={item.key} className='text-right'>
{t(item.labelKey)} / {tokenLabel}
</div>
))}
</>
) : (
<div className='text-right'>
{t('单价')} / {t('次')}
</div>
)}
</div>
{/* 官方价参考行:管理员维护的原厂牌价(不含分组倍率),供各分组折扣对照 */}
{officialDisplay && !isTierPricing && (
<div
className={`grid ${isPerToken ? '' : 'grid-cols-2'} items-center py-1.5 rounded-lg bg-gray-50/80 dark:bg-neutral-800/60`}
style={priceGridStyle}
>
<div className='flex items-center gap-1.5 pl-1'>
<BadgePercent size={12} className='text-gray-400' />
<span
className='text-sm text-gray-500 dark:text-gray-400'
title={t('管理员维护的模型原厂牌价,未含分组倍率,仅供对照')}
>
{t('官方价')}
</span>
</div>
{isPerToken ? (
<>
<div className='text-right'>
<span className='text-sm text-gray-500 dark:text-gray-400 line-through'>
{officialDisplay.input || '-'}
</span>
</div>
<div className='text-right'>
<span className='text-sm text-gray-500 dark:text-gray-400 line-through'>
{officialDisplay.output || '-'}
</span>
</div>
{extraPriceColumns.map((column) => (
<div key={column.key} className='text-right'>
<span className='text-sm text-gray-400'>-</span>
</div>
))}
</>
) : (
<div className='text-right'>
<span className='text-sm text-gray-500 dark:text-gray-400 line-through'>
{officialDisplay.perCall || '-'}
</span>
</div>
)}
</div>
)}
{/* 数据行 */}
<div className='space-y-0.5'>
{availableGroups.map((group, idx) => {
const priceData = groupPriceDataList[idx];
const discountText = getDiscountBadgeText(priceData);
return (
<div
key={group}
className={`grid ${isPerToken || isTierPricing ? '' : 'grid-cols-2'} items-center py-1.5`}
style={priceGridStyle}
>
<div className='flex items-center gap-1.5'>
<span
className={`w-1.5 h-1.5 rounded-full ${idx % 3 === 0 ? 'bg-emerald-500' : idx % 3 === 1 ? 'bg-blue-500' : 'bg-brand'}`}
/>
<span className='text-sm text-gray-700 dark:text-gray-200'>
{group}
</span>
{discountText && (
<span
className='px-1.5 py-[1px] rounded-full text-[10px] font-semibold leading-4
text-brand-deep dark:text-brand-from bg-brand/10 dark:bg-brand-deep/30
border border-brand/25 dark:border-brand-deep/50 select-none'
title={t(
'相比官方牌价的折扣,按当前计价分组实付价计算(已含您的等级折扣),仅供参考',
)}
>
{discountText}
</span>
)}
</div>
{isPerSecond ? (
videoTierColumns.map((col) => {
const tier = priceData.videoTiers?.find(
(vt) => vt.key === col.key,
);
return (
<div key={col.key} className='text-right'>
<span className='text-sm font-semibold text-emerald-600 dark:text-emerald-400'>
{tier?.price || '-'}
</span>
</div>
);
})
) : isPerImageResolution ? (
imageTierColumns.map((col) => {
const tier = priceData.imageTiers?.find(
(imageTier) => imageTier.key === col.key,
);
return (
<div key={col.key} className='text-right'>
<span className='text-sm font-semibold text-sky-600 dark:text-sky-400'>
{tier?.price || '-'}
</span>
</div>
);
})
) : isPerToken ? (
<>
<div className='text-right'>
<span className='text-sm font-semibold text-orange-600 dark:text-orange-400'>
{priceData.inputPrice}
</span>
</div>
<div className='text-right'>
<span className='text-sm font-semibold text-rose-600 dark:text-rose-400'>
{priceData.completionPrice || priceData.outputPrice}
</span>
</div>
{extraPriceColumns.map((column) => {
const item = priceData.extraPrices?.find(
(extra) => extra.key === column.key,
);
return (
<div key={column.key} className='text-right'>
<span className='text-sm font-semibold text-sky-600 dark:text-sky-400'>
{item?.price || '-'}
</span>
</div>
);
})}
</>
) : (
<div className='text-right'>
<span className='text-sm font-semibold text-brand-deep dark:text-brand-from'>
{priceData.price}
</span>
</div>
)}
</div>
);
})}
</div>
</div>
{availableGroups.length === 0 && (
<div className='text-center py-4 text-gray-400 dark:text-gray-400 text-xs'>
<Coins size={18} className='mx-auto mb-1 opacity-50' />
{t('暂无价格信息')}
</div>
)}
</div>
<Table
className='mm-detail-table'
size='small'
rowKey='key'
pagination={false}
scroll={{ x: 'max-content' }}
columns={[groupColumn, ...priceColumns]}
dataSource={dataSource}
locale={{
emptyText: (
<Empty
image={Empty.PRESENTED_IMAGE_SIMPLE}
description={t('暂无价格信息')}
/>
),
}}
/>
</section>
);
};
@@ -1,144 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { 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;
@@ -1,396 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import {
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;
@@ -1,151 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React, { 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;
@@ -1,322 +0,0 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import React from 'react';
import { 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;
};