🔍 feat: Show matched model names & counts for non-exact model rules

Summary
-------
1. **Backend**
   • `model/model_meta.go`
     – Add `MatchedModels []string` and `MatchedCount int` (ignored by GORM) to expose matching details in API responses.
   • `controller/model_meta.go`
     – When processing prefix/suffix/contains rules in `fillModelExtra`, collect every matched model name, fill `MatchedModels`, and calculate `MatchedCount`.

2. **Frontend**
   • `web/src/components/table/models/ModelsColumnDefs.js`
     – Import `Tooltip`.
     – Enhance `renderNameRule` to:
       – Display tag text like “前缀 5个模型” for non-exact rules.
       – Show a tooltip listing all matched model names on hover.

Impact
------
Users now see the total number of concrete models aggregated under each prefix/suffix/contains rule and can inspect the exact list via tooltip, improving transparency in model management.
This commit is contained in:
t0ng7u
2025-08-10 21:32:18 +08:00
parent 42d2394585
commit c8f7aa76e7
3 changed files with 35 additions and 6 deletions

View File

@@ -183,6 +183,9 @@ func fillModelExtra(m *model.Model) {
// 非精确匹配:计算并集
pricings := model.GetPricing()
// 匹配到的模型名称集合
matchedNames := make([]string, 0)
// 端点去重集合
endpointSet := make(map[constant.EndpointType]struct{})
// 已绑定渠道去重集合
@@ -206,6 +209,9 @@ func fillModelExtra(m *model.Model) {
continue
}
// 记录匹配到的模型名称
matchedNames = append(matchedNames, p.ModelName)
// 收集端点
for _, et := range p.SupportedEndpointTypes {
endpointSet[et] = struct{}{}
@@ -265,4 +271,8 @@ func fillModelExtra(m *model.Model) {
} else {
m.QuotaType = -1
}
// 设置匹配信息
m.MatchedModels = matchedNames
m.MatchedCount = len(matchedNames)
}