From 0081f825e5d5110ae08a4eb55fbcdfd61131bc97 Mon Sep 17 00:00:00 2001 From: NewName Date: Tue, 20 May 2025 17:04:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=90=9C=E7=B4=A2=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ghproxy/public/search.html | 24 +++++++++--------------- ghproxy/search.go | 16 ++++++++++------ 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/ghproxy/public/search.html b/ghproxy/public/search.html index e2de970..4c9c868 100644 --- a/ghproxy/public/search.html +++ b/ghproxy/public/search.html @@ -574,31 +574,27 @@ card.className = 'result-card'; // 确保所有字段都有值 - const name = result.name || ''; - const namespace = result.namespace || ''; - const description = result.description || '暂无描述'; + const name = result.repo_name || ''; + const description = result.short_description || '暂无描述'; const starCount = result.star_count || 0; const pullCount = result.pull_count || 0; - const lastUpdated = result.last_updated || new Date(); - const repoName = namespace ? `${namespace}/${name}` : name; + const repoOwner = result.repo_owner || ''; + const repoName = name; const officialBadge = result.is_official ? '官方' : ''; - const orgBadge = result.organization ? `By ${result.organization}` : ''; const automatedBadge = result.is_automated ? '自动构建' : ''; console.log('处理仓库:', { name, - namespace, + repoOwner, repoName, isOfficial: result.is_official, - organization: result.organization + isAutomated: result.is_automated }); card.innerHTML = `
${repoName} ${officialBadge} - ${orgBadge} - ${automatedBadge}
${description}
@@ -606,14 +602,14 @@ ${starCount > 0 ? `⭐ ${formatNumber(starCount)}` : ''} ${pullCount > 0 ? `⬇️ ${formatNumber(pullCount)}` : ''} - 更新于 ${formatTimeAgo(lastUpdated)} + 更新于 ${formatTimeAgo(result.last_updated)}
`; card.addEventListener('click', () => { - console.log('点击仓库:', name, namespace); + console.log('点击仓库:', name, repoOwner); currentRepo = result; - loadTags(namespace || 'library', name); + loadTags(repoOwner, name); }); resultsContainer.appendChild(card); @@ -657,8 +653,6 @@
${repoName} ${currentRepo.is_official ? '官方' : ''} - ${currentRepo.organization ? `By ${currentRepo.organization}` : ''} - ${currentRepo.is_automated ? '自动构建' : ''}
${currentRepo.description || '暂无描述'}
diff --git a/ghproxy/search.go b/ghproxy/search.go index 3daca11..5d64405 100644 --- a/ghproxy/search.go +++ b/ghproxy/search.go @@ -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) })