清理调试日志
This commit is contained in:
@@ -612,15 +612,12 @@
|
|||||||
targetRepo = repo.toLowerCase(); // 保存目标仓库名用于排序
|
targetRepo = repo.toLowerCase(); // 保存目标仓库名用于排序
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('执行搜索:', searchQuery);
|
|
||||||
const response = await fetch(`/search?q=${encodeURIComponent(searchQuery)}&page=${currentPage}&page_size=25`);
|
const response = await fetch(`/search?q=${encodeURIComponent(searchQuery)}&page=${currentPage}&page_size=25`);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(data.error || '搜索请求失败');
|
throw new Error(data.error || '搜索请求失败');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('搜索响应:', data);
|
|
||||||
|
|
||||||
// 更新总页数和分页状态
|
// 更新总页数和分页状态
|
||||||
totalPages = Math.ceil(data.count / 25);
|
totalPages = Math.ceil(data.count / 25);
|
||||||
@@ -674,7 +671,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isNaN(date.getTime())) {
|
if (isNaN(date.getTime())) {
|
||||||
console.warn('无法解析日期:', dateString);
|
|
||||||
return '未知时间';
|
return '未知时间';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -803,7 +799,6 @@
|
|||||||
async function loadTags(namespace, name) {
|
async function loadTags(namespace, name) {
|
||||||
showLoading();
|
showLoading();
|
||||||
try {
|
try {
|
||||||
console.log('加载标签:', namespace, name);
|
|
||||||
if (!namespace || !name) {
|
if (!namespace || !name) {
|
||||||
showToast('命名空间和镜像名称不能为空');
|
showToast('命名空间和镜像名称不能为空');
|
||||||
return;
|
return;
|
||||||
@@ -816,7 +811,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log('标签数据:', data);
|
|
||||||
displayTags(data);
|
displayTags(data);
|
||||||
showTagList();
|
showTagList();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -254,7 +254,6 @@ func searchDockerHub(ctx context.Context, query string, page, pageSize int) (*Se
|
|||||||
}
|
}
|
||||||
|
|
||||||
fullURL = fullURL + "?" + params.Encode()
|
fullURL = fullURL + "?" + params.Encode()
|
||||||
fmt.Printf("搜索URL: %s\n", fullURL)
|
|
||||||
|
|
||||||
// 发送请求
|
// 发送请求
|
||||||
req, err := http.NewRequestWithContext(ctx, "GET", fullURL, nil)
|
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")
|
params.Set("ordering", "last_updated")
|
||||||
|
|
||||||
fullURL := baseURL + "?" + params.Encode()
|
fullURL := baseURL + "?" + params.Encode()
|
||||||
fmt.Printf("获取标签URL: %s\n", fullURL)
|
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(ctx, "GET", fullURL, nil)
|
req, err := http.NewRequestWithContext(ctx, "GET", fullURL, nil)
|
||||||
if err != 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))
|
return nil, fmt.Errorf("请求失败: 状态码=%d, 响应=%s", resp.StatusCode, string(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打印响应内容以便调试
|
|
||||||
fmt.Printf("标签响应: %s\n", string(body))
|
|
||||||
|
|
||||||
// 解析响应
|
// 解析响应
|
||||||
var result struct {
|
var result struct {
|
||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
@@ -498,13 +493,6 @@ func getRepositoryTags(ctx context.Context, namespace, name string) ([]TagInfo,
|
|||||||
return nil, fmt.Errorf("解析响应失败: %v", err)
|
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)
|
searchCache.Set(cacheKey, result.Results)
|
||||||
return result.Results, nil
|
return result.Results, nil
|
||||||
@@ -529,11 +517,8 @@ func RegisterSearchRoute(r *gin.Engine) {
|
|||||||
fmt.Sscanf(ps, "%d", &pageSize)
|
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)
|
result, err := searchDockerHub(c.Request.Context(), query, page, pageSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("搜索失败: %v\n", err)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -546,8 +531,6 @@ func RegisterSearchRoute(r *gin.Engine) {
|
|||||||
namespace := c.Param("namespace")
|
namespace := c.Param("namespace")
|
||||||
name := c.Param("name")
|
name := c.Param("name")
|
||||||
|
|
||||||
fmt.Printf("获取标签请求: namespace=%s, name=%s\n", namespace, name)
|
|
||||||
|
|
||||||
if namespace == "" || name == "" {
|
if namespace == "" || name == "" {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "命名空间和名称不能为空"})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "命名空间和名称不能为空"})
|
||||||
return
|
return
|
||||||
@@ -555,7 +538,6 @@ func RegisterSearchRoute(r *gin.Engine) {
|
|||||||
|
|
||||||
tags, err := getRepositoryTags(c.Request.Context(), namespace, name)
|
tags, err := getRepositoryTags(c.Request.Context(), namespace, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("获取标签失败: %v\n", err)
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user