diff --git a/ghproxy/public/search.html b/ghproxy/public/search.html index 9a04b18..f592ec2 100644 --- a/ghproxy/public/search.html +++ b/ghproxy/public/search.html @@ -106,16 +106,18 @@ font-size: 1.2rem; font-weight: bold; margin-bottom: 10px; - color: #39c5bc; + color: #0091e2; display: flex; align-items: center; gap: 10px; + flex-wrap: wrap; } .result-description { color: var(--fontcolor); - margin-bottom: 15px; - font-size: 0.9rem; + margin: 10px 0; + font-size: 0.95rem; + line-height: 1.5; } .result-meta { @@ -125,6 +127,47 @@ font-size: 0.9rem; color: var(--fontcolor); opacity: 0.8; + margin-top: 15px; + } + + .meta-stats { + display: flex; + align-items: center; + gap: 15px; + } + + .meta-pulls { + font-size: 0.85rem; + color: #666; + } + + .badge { + padding: 4px 8px; + border-radius: 4px; + font-size: 0.8rem; + font-weight: normal; + white-space: nowrap; + } + + .badge-official { + background-color: #28a745; + color: white; + } + + .badge-organization { + background-color: #6c757d; + color: white; + } + + .badge-automated { + background-color: #17a2b8; + color: white; + } + + .meta-item { + display: inline-flex; + align-items: center; + white-space: nowrap; } .back-button { @@ -211,23 +254,6 @@ background-color: #2ea8a0; } - .badge { - padding: 4px 8px; - border-radius: 4px; - font-size: 0.8rem; - font-weight: normal; - } - - .badge-official { - background-color: #39c5bc; - color: white; - } - - .badge-organization { - background-color: #6c757d; - color: white; - } - .tag-list { margin-top: 20px; display: none; @@ -352,45 +378,6 @@ .back-to-search:hover { text-decoration: underline; } - - .meta-item { - display: inline-flex; - align-items: center; - margin-right: 15px; - color: var(--fontcolor); - opacity: 0.8; - } - - .badge-automated { - background-color: #28a745; - color: white; - margin-left: 5px; - } - - .tag-meta { - display: flex; - flex-wrap: wrap; - gap: 15px; - margin: 10px 0; - font-size: 0.9rem; - color: var(--fontcolor); - opacity: 0.8; - } - - .vulnerability-indicator { - display: inline-flex; - align-items: center; - gap: 5px; - margin-left: 10px; - } - - .arch-item { - background-color: var(--inputcolor); - padding: 5px 10px; - border-radius: 5px; - font-size: 0.8rem; - cursor: help; - } @@ -546,16 +533,25 @@ } function formatTimeAgo(dateString) { + if (!dateString) return '未知时间'; + const date = new Date(dateString); + if (isNaN(date.getTime())) return '未知时间'; + const now = new Date(); const diffTime = Math.abs(now - date); - const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); + const diffMinutes = Math.floor(diffTime / (1000 * 60)); + const diffHours = Math.floor(diffTime / (1000 * 60 * 60)); + const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24)); + const diffMonths = Math.floor(diffDays / 30); + const diffYears = Math.floor(diffDays / 365); - if (diffDays === 1) return '昨天'; + if (diffMinutes < 60) return `${diffMinutes}分钟前`; + if (diffHours < 24) return `${diffHours}小时前`; if (diffDays < 7) return `${diffDays}天前`; if (diffDays < 30) return `${Math.floor(diffDays / 7)}周前`; - if (diffDays < 365) return `${Math.floor(diffDays / 30)}个月前`; - return `${Math.floor(diffDays / 365)}年前`; + if (diffMonths < 12) return `${diffMonths}个月前`; + return `${diffYears}年前`; } function displayResults(results) { @@ -567,49 +563,50 @@ return; } - console.log('显示搜索结果:', results); - results.forEach(result => { const card = document.createElement('div'); card.className = 'result-card'; - // 确保所有字段都有值 const name = result.repo_name || ''; const description = result.short_description || '暂无描述'; const starCount = result.star_count || 0; const pullCount = result.pull_count || 0; - const repoOwner = result.repo_owner || ''; - const repoName = name; - const officialBadge = result.is_official ? '官方' : ''; - const automatedBadge = result.is_automated ? '自动构建' : ''; + const pullsLastWeek = result.pulls_last_week || 0; + const lastUpdated = result.last_updated || ''; + const organization = result.affiliation || ''; - console.log('处理仓库:', { - name, - repoOwner, - repoName, - isOfficial: result.is_official, - isAutomated: result.is_automated - }); + const badges = []; + if (result.is_official) badges.push('官方'); + if (organization) badges.push(`By ${organization}`); + if (result.is_automated) badges.push('自动构建'); + + const stats = []; + if (pullCount > 0) stats.push(`${formatNumber(pullCount)}+`); + if (starCount > 0) stats.push(`${formatNumber(starCount)}`); card.innerHTML = `
- ${repoName} - ${officialBadge} + ${name} + ${badges.join(' ')}
${description}
- - ${starCount > 0 ? `⭐ ${formatNumber(starCount)}` : ''} - ${pullCount > 0 ? `⬇️ ${formatNumber(pullCount)}` : ''} - - 更新于 ${formatTimeAgo(result.last_updated)} +
+ ${stats.length > 0 ? `${stats.join(' • ')}` : ''} + ${lastUpdated ? `更新于 ${formatTimeAgo(lastUpdated)}` : ''} +
+ ${pullsLastWeek > 0 ? ` +
+ 本周拉取: ${formatNumber(pullsLastWeek)} +
+ ` : ''}
`; card.addEventListener('click', () => { - console.log('点击仓库:', name, repoOwner); + console.log('点击仓库:', name); currentRepo = result; - loadTags(repoOwner, name); + loadTags(result.is_official ? 'library' : (result.repo_owner || ''), name); }); resultsContainer.appendChild(card); diff --git a/ghproxy/search.go b/ghproxy/search.go index cb2898c..fc649d4 100644 --- a/ghproxy/search.go +++ b/ghproxy/search.go @@ -31,6 +31,10 @@ type Repository struct { StarCount int `json:"star_count"` PullCount int `json:"pull_count"` RepoOwner string `json:"repo_owner"` + LastUpdated string `json:"last_updated"` + Status int `json:"status"` + Organization string `json:"affiliation"` + PullsLastWeek int `json:"pulls_last_week"` } // TagInfo 标签信息