清理调试日志

This commit is contained in:
NewName
2025-05-20 20:03:09 +08:00
parent 69a1b66638
commit d91ae9d844
2 changed files with 0 additions and 24 deletions

View File

@@ -612,15 +612,12 @@
targetRepo = repo.toLowerCase(); // 保存目标仓库名用于排序
}
console.log('执行搜索:', searchQuery);
const response = await fetch(`/search?q=${encodeURIComponent(searchQuery)}&page=${currentPage}&page_size=25`);
const data = await response.json();
if (!response.ok) {
throw new Error(data.error || '搜索请求失败');
}
console.log('搜索响应:', data);
// 更新总页数和分页状态
totalPages = Math.ceil(data.count / 25);
@@ -674,7 +671,6 @@
}
if (isNaN(date.getTime())) {
console.warn('无法解析日期:', dateString);
return '未知时间';
}
}
@@ -803,7 +799,6 @@
async function loadTags(namespace, name) {
showLoading();
try {
console.log('加载标签:', namespace, name);
if (!namespace || !name) {
showToast('命名空间和镜像名称不能为空');
return;
@@ -816,7 +811,6 @@
}
const data = await response.json();
console.log('标签数据:', data);
displayTags(data);
showTagList();
} catch (error) {

View File

@@ -254,7 +254,6 @@ func searchDockerHub(ctx context.Context, query string, page, pageSize int) (*Se
}
fullURL = fullURL + "?" + params.Encode()
fmt.Printf("搜索URL: %s\n", fullURL)
// 发送请求
req, err := http.NewRequestWithContext(ctx, "GET", fullURL, nil)
@@ -454,7 +453,6 @@ func getRepositoryTags(ctx context.Context, namespace, name string) ([]TagInfo,
params.Set("ordering", "last_updated")
fullURL := baseURL + "?" + params.Encode()
fmt.Printf("获取标签URL: %s\n", fullURL)
req, err := http.NewRequestWithContext(ctx, "GET", fullURL, nil)
if err != nil {
@@ -484,9 +482,6 @@ func getRepositoryTags(ctx context.Context, namespace, name string) ([]TagInfo,
return nil, fmt.Errorf("请求失败: 状态码=%d, 响应=%s", resp.StatusCode, string(body))
}
// 打印响应内容以便调试
fmt.Printf("标签响应: %s\n", string(body))
// 解析响应
var result struct {
Count int `json:"count"`
@@ -498,13 +493,6 @@ func getRepositoryTags(ctx context.Context, namespace, name string) ([]TagInfo,
return nil, fmt.Errorf("解析响应失败: %v", err)
}
// 打印解析后的结果
fmt.Printf("标签结果: 总数=%d, 结果数=%d\n", result.Count, len(result.Results))
for i, tag := range result.Results {
fmt.Printf("标签[%d]: 名称=%s, 大小=%d, 更新时间=%v\n",
i, tag.Name, tag.FullSize, tag.LastUpdated)
}
// 缓存结果
searchCache.Set(cacheKey, result.Results)
return result.Results, nil
@@ -529,11 +517,8 @@ func RegisterSearchRoute(r *gin.Engine) {
fmt.Sscanf(ps, "%d", &pageSize)
}
fmt.Printf("搜索请求: query=%s, page=%d, pageSize=%d\n", query, page, pageSize)
result, err := searchDockerHub(c.Request.Context(), query, page, pageSize)
if err != nil {
fmt.Printf("搜索失败: %v\n", err)
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
@@ -546,8 +531,6 @@ func RegisterSearchRoute(r *gin.Engine) {
namespace := c.Param("namespace")
name := c.Param("name")
fmt.Printf("获取标签请求: namespace=%s, name=%s\n", namespace, name)
if namespace == "" || name == "" {
c.JSON(http.StatusBadRequest, gin.H{"error": "命名空间和名称不能为空"})
return
@@ -555,7 +538,6 @@ func RegisterSearchRoute(r *gin.Engine) {
tags, err := getRepositoryTags(c.Request.Context(), namespace, name)
if err != nil {
fmt.Printf("获取标签失败: %v\n", err)
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}