diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index e6ec03b..f5062c2 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -148,14 +148,8 @@ "pricing.status": "Status", "pricing.online": "Online", "pricing.unknown": "Unknown", - "pricing.catAll": "All", - "pricing.catChat": "Chat", - "pricing.catCompletion": "Completion", - "pricing.catEmbedding": "Embedding", - "pricing.catImage": "Image", - "pricing.catAudio": "Audio", - "pricing.catVideo": "Video", - "pricing.catRerank": "Rerank", + "pricing.vendor": "Vendor", + "pricing.allVendors": "All", "packages.title": "Packages & Plans", "packages.subtitle": "Choose a package that fits your usage. All plans include access to all available models.", diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index 2dec961..3038a30 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -148,14 +148,8 @@ "pricing.status": "状态", "pricing.online": "在线", "pricing.unknown": "未知", - "pricing.catAll": "全部", - "pricing.catChat": "对话", - "pricing.catCompletion": "补全", - "pricing.catEmbedding": "向量", - "pricing.catImage": "图像", - "pricing.catAudio": "音频", - "pricing.catVideo": "视频", - "pricing.catRerank": "重排序", + "pricing.vendor": "厂商", + "pricing.allVendors": "全部", "packages.title": "套餐方案", "packages.subtitle": "选择适合您用量的套餐。所有方案均可访问全部可用模型。", diff --git a/src/pages/Pricing.jsx b/src/pages/Pricing.jsx index 1634a01..7658a83 100644 --- a/src/pages/Pricing.jsx +++ b/src/pages/Pricing.jsx @@ -2,28 +2,21 @@ import React, { useState, useEffect, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; import { getSiteModels } from '../api'; -const CATEGORIES = [ - { value: '', icon: '🌐', labelKey: 'pricing.catAll' }, - { value: 'chat', icon: '💬', labelKey: 'pricing.catChat' }, - { value: 'completion', icon: '✍️', labelKey: 'pricing.catCompletion' }, - { value: 'embedding', icon: '📐', labelKey: 'pricing.catEmbedding' }, - { value: 'image', icon: '🖼️', labelKey: 'pricing.catImage' }, - { value: 'audio', icon: '🎵', labelKey: 'pricing.catAudio' }, - { value: 'video', icon: '🎬', labelKey: 'pricing.catVideo' }, - { value: 'rerank', icon: '🔀', labelKey: 'pricing.catRerank' }, -]; - export default function Pricing() { const { t } = useTranslation(); const [models, setModels] = useState([]); + const [vendors, setVendors] = useState([]); const [search, setSearch] = useState(''); - const [category, setCategory] = useState(''); + const [vendor, setVendor] = useState(''); const [loading, setLoading] = useState(true); useEffect(() => { getSiteModels() .then((r) => { - if (r.data.success) setModels(r.data.data || []); + if (r.data.success) { + setModels(r.data.data || []); + setVendors(r.data.vendors || []); + } }) .catch(() => {}) .finally(() => setLoading(false)); @@ -31,17 +24,17 @@ export default function Pricing() { const enabledModels = models.filter((m) => m.enabled !== false); - // Collect categories that actually have models - const availableCategories = useMemo(() => { - const cats = new Set(enabledModels.map((m) => m.category || 'chat')); - return CATEGORIES.filter((c) => c.value === '' || cats.has(c.value)); - }, [enabledModels]); + // Collect vendor names that actually have models + const availableVendors = useMemo(() => { + const vendorNames = new Set(enabledModels.map((m) => m.vendor_name).filter(Boolean)); + return vendors.filter((v) => vendorNames.has(v.name)); + }, [enabledModels, vendors]); const filtered = useMemo(() => { let list = enabledModels; - // Category filter - if (category) { - list = list.filter((m) => (m.category || 'chat') === category); + // Vendor filter + if (vendor) { + list = list.filter((m) => m.vendor_name === vendor); } // Search filter if (search) { @@ -53,7 +46,7 @@ export default function Pricing() { // Sort by input_price ascending list = [...list].sort((a, b) => (Number(a.input_price) || 0) - (Number(b.input_price) || 0)); return list; - }, [enabledModels, category, search]); + }, [enabledModels, vendor, search]); if (loading) { return ( @@ -72,23 +65,34 @@ export default function Pricing() {
- {/* Category Filter */} -