diff --git a/ghproxy/public/search.html b/ghproxy/public/search.html index 7b1299e..63d1cd4 100644 --- a/ghproxy/public/search.html +++ b/ghproxy/public/search.html @@ -647,7 +647,15 @@ card.className = 'result-card'; // 构建显示名称 - const displayName = result.is_official ? result.name : `${result.namespace}/${result.name}`; + let displayName = result.name; + if (result.is_official) { + // 对于官方镜像,去掉 library/ 前缀 + displayName = result.name.replace('library/', ''); + } else { + // 对于非官方镜像,显示完整路径 + displayName = `${result.namespace}/${result.name}`; + } + const description = result.short_description || '暂无描述'; const starCount = result.star_count || 0; const pullCount = result.pull_count || 0; @@ -660,8 +668,8 @@ if (organization) badges.push(`By ${organization}`); const stats = []; - if (pullCount > 0) stats.push(`${formatNumber(pullCount)}+`); - if (starCount > 0) stats.push(`${formatNumber(starCount)}`); + if (starCount > 0) stats.push(`⭐ ${formatNumber(starCount)}`); + if (pullCount > 0) stats.push(`⬇️ ${formatNumber(pullCount)}+`); card.innerHTML = `
@@ -671,7 +679,7 @@
${description}
- ${stats.length > 0 ? `${stats.join(' • ')}` : ''} + ${stats.join(' ')} ${lastUpdated ? `更新于 ${formatTimeAgo(lastUpdated)}` : ''}
${pullsLastWeek > 0 ? ` @@ -686,7 +694,7 @@ card.addEventListener('click', () => { currentRepo = result; const namespace = result.namespace || (result.is_official ? 'library' : ''); - const repoName = result.name || result.repo_name; + const repoName = result.name.replace('library/', ''); if (!namespace || !repoName) { showToast('无效的仓库信息'); return; diff --git a/ghproxy/search.go b/ghproxy/search.go index 75b94ae..faf6295 100644 --- a/ghproxy/search.go +++ b/ghproxy/search.go @@ -161,8 +161,15 @@ func searchDockerHub(ctx context.Context, query string, page, pageSize int) (*Se // 处理搜索结果 for i := range result.Results { - // 从 repo_name 中提取 namespace - if !result.Results[i].IsOfficial { + if result.Results[i].IsOfficial { + // 确保官方镜像有正确的名称格式 + if !strings.Contains(result.Results[i].Name, "/") { + result.Results[i].Name = "library/" + result.Results[i].Name + } + // 设置命名空间为 library + result.Results[i].Namespace = "library" + } else { + // 从 repo_name 中提取 namespace parts := strings.Split(result.Results[i].Name, "/") if len(parts) > 1 { result.Results[i].Namespace = parts[0] @@ -170,9 +177,6 @@ func searchDockerHub(ctx context.Context, query string, page, pageSize int) (*Se } else { result.Results[i].Namespace = result.Results[i].RepoOwner } - } else { - result.Results[i].Name = strings.TrimPrefix(result.Results[i].Name, "library/") - result.Results[i].Namespace = "library" } }