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
@@ -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;
@@ -0,0 +1,40 @@
/*
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 'antd';
import { getLobeHubIcon } from '../../../../helpers';
/**
* 原型 .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 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
@@ -0,0 +1,34 @@
/*
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 { theme } from 'antd';
/**
* 模型超市局部 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,
};
};