修复搜索结果显示

This commit is contained in:
NewName
2025-05-20 17:04:13 +08:00
parent fc185c29ed
commit 0081f825e5
2 changed files with 19 additions and 21 deletions

View File

@@ -24,16 +24,13 @@ type SearchResult struct {
// Repository 仓库信息
type Repository struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
Description string `json:"description"`
Name string `json:"repo_name"`
Description string `json:"short_description"`
IsOfficial bool `json:"is_official"`
IsAutomated bool `json:"is_automated"`
StarCount int `json:"star_count"`
PullCount int `json:"pull_count"`
LastUpdated time.Time `json:"last_updated"`
Status int `json:"status"`
Organization string `json:"organization,omitempty"`
RepoOwner string `json:"repo_owner"`
}
// TagInfo 标签信息
@@ -269,6 +266,13 @@ func RegisterSearchRoute(r *gin.Engine) {
return
}
// 处理官方镜像的情况
for i := range result.Results {
if result.Results[i].IsOfficial {
result.Results[i].Name = strings.TrimPrefix(result.Results[i].Name, "library/")
}
}
c.JSON(http.StatusOK, result)
})