mirror of
https://fastgit.cc/github.com/HKUDS/CLI-Anything
synced 2026-04-20 21:00:28 +08:00
improve CLI-Hub
This commit is contained in:
@@ -258,6 +258,21 @@
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.nav-link-stars {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 2.9rem;
|
||||
padding: 0.14rem 0.52rem;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
color: var(--text);
|
||||
font-size: 0.73rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
.theme-toggle {
|
||||
width: 42px;
|
||||
padding: 0;
|
||||
@@ -1837,6 +1852,7 @@
|
||||
<a class="nav-link" href="https://github.com/HKUDS/CLI-Anything" target="_blank">
|
||||
<svg viewBox="0 0 98 96" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6C29.304 70.25 17.9 66.013 17.9 47.02c0-5.52 1.94-10.046 5.127-13.58-.486-1.302-2.264-6.437.486-13.34 0 0 4.206-1.302 13.59 5.216 3.963-1.14 8.17-1.628 12.34-1.628 4.17 0 8.376.568 12.34 1.628 9.384-6.518 13.59-5.216 13.59-5.216 2.75 6.903.972 12.038.486 13.34 3.268 3.534 5.127 8.06 5.127 13.58 0 19.074-11.485 23.15-22.328 24.29 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"/></svg>
|
||||
GitHub
|
||||
<span class="nav-link-stars" data-github-stars aria-label="GitHub star count">--</span>
|
||||
</a>
|
||||
<a class="nav-link" href="https://github.com/HKUDS/CLI-Anything/blob/main/CONTRIBUTING.md" target="_blank">Contribute</a>
|
||||
<button class="theme-toggle" onclick="toggleTheme()" aria-label="Toggle theme">
|
||||
@@ -2107,6 +2123,7 @@
|
||||
});
|
||||
|
||||
const REPO = 'https://github.com/HKUDS/CLI-Anything';
|
||||
const GITHUB_REPO_API = 'https://api.github.com/repos/HKUDS/CLI-Anything';
|
||||
const REGISTRY_URLS = [
|
||||
'../../registry.json',
|
||||
'https://raw.githubusercontent.com/HKUDS/CLI-Anything/main/registry.json'
|
||||
@@ -2147,6 +2164,34 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
function formatCompactCount(value) {
|
||||
return new Intl.NumberFormat('en', {
|
||||
notation: 'compact',
|
||||
maximumFractionDigits: value >= 10000 ? 0 : 1,
|
||||
}).format(value);
|
||||
}
|
||||
|
||||
async function loadGitHubStars() {
|
||||
try {
|
||||
const resp = await fetch(GITHUB_REPO_API, {
|
||||
headers: { Accept: 'application/vnd.github+json' }
|
||||
});
|
||||
if (!resp.ok) return;
|
||||
|
||||
const repo = await resp.json();
|
||||
const stars = repo.stargazers_count;
|
||||
if (typeof stars !== 'number') return;
|
||||
|
||||
document.querySelectorAll('[data-github-stars]').forEach((el) => {
|
||||
el.textContent = formatCompactCount(stars);
|
||||
el.setAttribute('aria-label', stars.toLocaleString('en-US') + ' GitHub stars');
|
||||
el.title = stars.toLocaleString('en-US') + ' GitHub stars';
|
||||
});
|
||||
} catch (_) {
|
||||
// Keep fallback placeholder when GitHub API is unavailable.
|
||||
}
|
||||
}
|
||||
|
||||
async function loadRegistries() {
|
||||
try {
|
||||
const [harnessData, publicData, dates] = await Promise.all([
|
||||
@@ -2706,6 +2751,7 @@
|
||||
}
|
||||
|
||||
loadVisitorStats();
|
||||
loadGitHubStars();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
--text: #fafafa;
|
||||
--text-secondary: #a1a1aa;
|
||||
--text-tertiary: #71717a;
|
||||
--hero-neutral-top: #e7ecf2;
|
||||
--hero-neutral-bottom: #b8c1cd;
|
||||
--accent: #3b82f6;
|
||||
--accent-muted: #2563eb;
|
||||
--green: #22c55e;
|
||||
@@ -37,6 +39,8 @@
|
||||
--text: #09090b;
|
||||
--text-secondary: #52525b;
|
||||
--text-tertiary: #71717a;
|
||||
--hero-neutral-top: #7f8894;
|
||||
--hero-neutral-bottom: #a8b1bc;
|
||||
--accent: #2563eb;
|
||||
--accent-muted: #1d4ed8;
|
||||
--green: #16a34a;
|
||||
@@ -103,6 +107,21 @@
|
||||
|
||||
.nav-link svg { width: 15px; height: 15px; flex-shrink: 0; }
|
||||
|
||||
.nav-link-stars {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 2.8rem;
|
||||
padding: 0.1rem 0.45rem;
|
||||
border-radius: 999px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
font-size: 0.72rem;
|
||||
font-variant-numeric: tabular-nums;
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
/* ── Theme toggle ── */
|
||||
.theme-toggle {
|
||||
display: inline-flex;
|
||||
@@ -148,7 +167,14 @@
|
||||
}
|
||||
|
||||
.hero-accent { color: var(--accent); }
|
||||
.hero-dim { color: var(--text-tertiary); }
|
||||
.hero-dim {
|
||||
color: var(--hero-neutral-bottom);
|
||||
background: linear-gradient(180deg, var(--hero-neutral-top) 0%, var(--hero-neutral-bottom) 100%);
|
||||
-webkit-background-clip: text;
|
||||
background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.hero-tagline {
|
||||
font-size: 1.15rem;
|
||||
@@ -1222,6 +1248,7 @@
|
||||
<a class="nav-link" href="https://github.com/HKUDS/CLI-Anything" target="_blank">
|
||||
<svg viewBox="0 0 98 96" fill="currentColor"><path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6C29.304 70.25 17.9 66.013 17.9 47.02c0-5.52 1.94-10.046 5.127-13.58-.486-1.302-2.264-6.437.486-13.34 0 0 4.206-1.302 13.59 5.216 3.963-1.14 8.17-1.628 12.34-1.628 4.17 0 8.376.568 12.34 1.628 9.384-6.518 13.59-5.216 13.59-5.216 2.75 6.903.972 12.038.486 13.34 3.268 3.534 5.127 8.06 5.127 13.58 0 19.074-11.485 23.15-22.328 24.29 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"/></svg>
|
||||
GitHub
|
||||
<span class="nav-link-stars" data-github-stars aria-label="GitHub star count">--</span>
|
||||
</a>
|
||||
<a class="nav-link" href="https://github.com/HKUDS/CLI-Anything/blob/main/CONTRIBUTING.md" target="_blank">
|
||||
Contribute
|
||||
@@ -1413,6 +1440,7 @@
|
||||
});
|
||||
|
||||
const REPO = 'https://github.com/HKUDS/CLI-Anything';
|
||||
const GITHUB_REPO_API = 'https://api.github.com/repos/HKUDS/CLI-Anything';
|
||||
const REGISTRY_URLS = [
|
||||
'../../registry.json',
|
||||
'https://raw.githubusercontent.com/HKUDS/CLI-Anything/main/registry.json'
|
||||
@@ -1455,6 +1483,34 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
function formatCompactCount(value) {
|
||||
return new Intl.NumberFormat('en', {
|
||||
notation: 'compact',
|
||||
maximumFractionDigits: value >= 10000 ? 0 : 1,
|
||||
}).format(value);
|
||||
}
|
||||
|
||||
async function loadGitHubStars() {
|
||||
try {
|
||||
const resp = await fetch(GITHUB_REPO_API, {
|
||||
headers: { 'Accept': 'application/vnd.github+json' }
|
||||
});
|
||||
if (!resp.ok) return;
|
||||
|
||||
const repo = await resp.json();
|
||||
const stars = repo.stargazers_count;
|
||||
if (typeof stars !== 'number') return;
|
||||
|
||||
document.querySelectorAll('[data-github-stars]').forEach(el => {
|
||||
el.textContent = formatCompactCount(stars);
|
||||
el.setAttribute('aria-label', `${stars.toLocaleString('en-US')} GitHub stars`);
|
||||
el.title = `${stars.toLocaleString('en-US')} GitHub stars`;
|
||||
});
|
||||
} catch (_) {
|
||||
// Keep fallback placeholder when GitHub API is unavailable.
|
||||
}
|
||||
}
|
||||
|
||||
async function loadRegistries() {
|
||||
try {
|
||||
const [harnessData, publicData, dates] = await Promise.all([
|
||||
@@ -2048,6 +2104,7 @@
|
||||
}
|
||||
|
||||
loadVisitorStats();
|
||||
loadGitHubStars();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user