From aee5b8caa7e5d9440d1a355d662dff0f7ef030cc Mon Sep 17 00:00:00 2001 From: t0ng7u Date: Fri, 29 Aug 2025 23:42:33 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(pricing):=20add=20default=20ve?= =?UTF-8?q?ndor=20icons=20with=20LobeHub=20color=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add defaultVendorIcons mapping for major AI vendors - Update getOrCreateVendor to automatically set vendor icons - Add getDefaultVendorIcon helper function - Support LobeHub icons Color variants (e.g., Claude.Color, Gemini.Color) - Fix issue where default vendors were created without icons This ensures that when new models are encountered, their vendors will be created with appropriate colored icons for better UI display. Affected vendors include: - OpenAI, Anthropic, Google, Moonshot, 智谱, 阿里巴巴 - DeepSeek, MiniMax, 百度, 讯飞, 腾讯, Cohere - Cloudflare, 360, 零一万物, Jina, Mistral, xAI - Meta, 字节跳动, 快手, 即梦, Vidu, Microsoft/Azure --- model/pricing_default.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/model/pricing_default.go b/model/pricing_default.go index 912bbe25..db64cafb 100644 --- a/model/pricing_default.go +++ b/model/pricing_default.go @@ -37,6 +37,36 @@ var defaultVendorRules = map[string]string{ "vidu": "Vidu", } +// 供应商默认图标映射 +var defaultVendorIcons = map[string]string{ + "OpenAI": "OpenAI", + "Anthropic": "Claude.Color", + "Google": "Gemini.Color", + "Moonshot": "Moonshot", + "智谱": "Zhipu.Color", + "阿里巴巴": "Qwen.Color", + "DeepSeek": "DeepSeek.Color", + "MiniMax": "Minimax.Color", + "百度": "Wenxin.Color", + "讯飞": "Spark.Color", + "腾讯": "Hunyuan.Color", + "Cohere": "Cohere.Color", + "Cloudflare": "Cloudflare.Color", + "360": "Ai360.Color", + "零一万物": "Yi.Color", + "Jina": "Jina", + "Mistral": "Mistral.Color", + "xAI": "XAI", + "Meta": "Ollama", + "字节跳动": "Doubao.Color", + "快手": "Kling.Color", + "即梦": "Jimeng.Color", + "Vidu": "Vidu", + "微软": "AzureAI", + "Microsoft": "AzureAI", + "Azure": "AzureAI", +} + // initDefaultVendorMapping 简化的默认供应商映射 func initDefaultVendorMapping(metaMap map[string]*Model, vendorMap map[int]*Vendor, enableAbilities []AbilityWithChannel) { for _, ability := range enableAbilities { @@ -78,6 +108,7 @@ func getOrCreateVendor(vendorName string, vendorMap map[int]*Vendor) int { newVendor := &Vendor{ Name: vendorName, Status: 1, + Icon: getDefaultVendorIcon(vendorName), } if err := newVendor.Insert(); err != nil { @@ -87,3 +118,11 @@ func getOrCreateVendor(vendorName string, vendorMap map[int]*Vendor) int { vendorMap[newVendor.Id] = newVendor return newVendor.Id } + +// 获取供应商默认图标 +func getDefaultVendorIcon(vendorName string) string { + if icon, exists := defaultVendorIcons[vendorName]; exists { + return icon + } + return "" +}