From 3a32ab11dd7f725987d9346ed54d9565b6cb2ab8 Mon Sep 17 00:00:00 2001 From: fengsilin Date: Wed, 25 Mar 2026 18:09:11 +0800 Subject: [PATCH] =?UTF-8?q?feat(model):=20=E6=B7=BB=E5=8A=A0=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E7=B1=BB=E5=9E=8B=E5=AD=97=E6=AE=B5=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 后端 Update 函数添加 type 字段支持更新 - 前端 EditModelModal 添加模型类型下拉选择器 - 新增 MODEL_TYPE_OPTIONS 共享常量(与后端 ModelType 一致) - 添加中英文 i18n 翻译 - 修复首页"全部供应商"计数显示错误的 bug Co-Authored-By: Claude Opus 4.6 --- model/model_meta.go | 2 +- .../table/models/modals/EditModelModal.jsx | 21 +++++++++++++++++++ web/src/constants/common.constant.js | 13 ++++++++++++ web/src/i18n/locales/en.json | 9 ++++++++ web/src/i18n/locales/zh-CN.json | 11 +++++++++- web/src/pages/Home/HomePricingFilters.jsx | 15 ++++++++----- 6 files changed, 64 insertions(+), 7 deletions(-) diff --git a/model/model_meta.go b/model/model_meta.go index 4f76898..b734350 100644 --- a/model/model_meta.go +++ b/model/model_meta.go @@ -89,7 +89,7 @@ func (mi *Model) Update() error { mi.UpdatedTime = common.GetTimestamp() // 使用 Select 强制更新所有字段,包括零值 return DB.Model(&Model{}).Where("id = ?", mi.Id). - Select("model_name", "description", "icon", "tags", "vendor_id", "endpoints", "status", "sync_official", "name_rule", "updated_time"). + Select("model_name", "description", "icon", "tags", "type", "vendor_id", "endpoints", "status", "sync_official", "name_rule", "updated_time"). Updates(mi).Error } diff --git a/web/src/components/table/models/modals/EditModelModal.jsx b/web/src/components/table/models/modals/EditModelModal.jsx index 12ca48e..683d13d 100644 --- a/web/src/components/table/models/modals/EditModelModal.jsx +++ b/web/src/components/table/models/modals/EditModelModal.jsx @@ -38,6 +38,7 @@ import { IconAlertTriangle, IconLink } from '@douyinfe/semi-icons'; import { API, showError, showSuccess } from '../../../../helpers'; import { useTranslation } from 'react-i18next'; import { useIsMobile } from '../../../../hooks/common/useIsMobile'; +import { MODEL_TYPE_OPTIONS } from '../../../../constants/common.constant'; const { Text, Title } = Typography; @@ -117,6 +118,7 @@ const EditModelModal = (props) => { description: '', icon: '', tags: [], + type: 1, // 默认对话模型 vendor_id: undefined, vendor: '', vendor_icon: '', @@ -330,6 +332,25 @@ const EditModelModal = (props) => { /> + + ({ + label: t(o.label), + value: o.value, + }))} + rules={[ + { required: true, message: t('请选择模型类型') }, + ]} + extraText={t( + '选择模型的类型,用于分类和筛选', + )} + style={{ width: '100%' }} + /> + + { } }); const vendors = Array.from(vendorSet).sort(); - const getCount = (v) => { + const getVendorCount = () => { + // 计算供应商数量(包含未知供应商) + const count = vendorSet.size + (hasUnknown ? 1 : 0); + return count; + }; + const getModelCount = (v) => { if (v === 'all') return vendorModels.length; if (v === 'unknown') return vendorModels.filter((m) => !m.vendor_name).length; return vendorModels.filter((m) => m.vendor_name === v).length; }; const items = [ - { value: 'all', label: t('全部供应商'), tagCount: getCount('all'), disabled: (models || []).length === 0 }, + { value: 'all', label: t('全部供应商'), tagCount: getVendorCount(), disabled: (models || []).length === 0 }, ]; vendors.forEach((v) => { - const count = getCount(v); + const count = getModelCount(v); items.push({ value: v, label: v, @@ -93,8 +98,8 @@ const HomePricingFilters = ({ t }) => { items.push({ value: 'unknown', label: t('未知供应商'), - tagCount: getCount('unknown'), - disabled: getCount('unknown') === 0, + tagCount: getModelCount('unknown'), + disabled: getModelCount('unknown') === 0, }); } return items;