From 7776df1268763ca8b201c121420e6f5ecb347674 Mon Sep 17 00:00:00 2001 From: hehh Date: Tue, 25 Nov 2025 16:47:21 +0800 Subject: [PATCH] =?UTF-8?q?feat(stats):=20=E9=87=8D=E6=9E=84=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E5=8C=BA=E5=9F=9F=E6=A0=B7=E5=BC=8F=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=95=B0=E6=8D=AE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 使用grid布局重构统计区域,替换原有的flex布局 - 添加响应式设计,适配PC、平板和移动端显示 - 为统计项添加悬停效果和过渡动画 - 集成verCount统计服务,替换不蒜子统计 - 添加数据格式化功能,支持K/W/M单位显示 - 增加访客数和访问量的国际化支持 - 优化统计数字的显示格式和可读性 --- about.html | 96 +++++++++++++++++++++++++++++++++++++------------- css/about.css | 97 +++++++++++++++++++++++++++++++++++++++++++-------- js/about.js | 17 ++++++++- 3 files changed, 170 insertions(+), 40 deletions(-) diff --git a/about.html b/about.html index 39374d0..005300a 100644 --- a/about.html +++ b/about.html @@ -151,10 +151,12 @@ Followers
- - -- - - Visitors + + Visit num +
+
+ + Visitors
@@ -324,11 +326,16 @@ - - + + - - + // 监听不蒜子数据更新并格式化 + function initFormatter() { + const pvEl = document.getElementById('busuanzi_value_site_pv'); + const uvEl = document.getElementById('busuanzi_value_site_uv'); - - + if (!pvEl && !uvEl) return; - - diff --git a/css/about.css b/css/about.css index be3dc08..7854b64 100644 --- a/css/about.css +++ b/css/about.css @@ -1769,37 +1769,105 @@ body { /* --- Stats --- */ .area-stats { - display: flex; - flex-direction: column; - justify-content: space-around; - padding: 20px 30px; + display: grid; + grid-template-columns: repeat(5, 1fr); + gap: 8px; + padding: 20px; + border-radius: 16px; + background: rgba(255, 255, 255, 0.7); + backdrop-filter: blur(10px); + -webkit-backdrop-filter: blur(10px); + border: 1px solid rgba(128, 128, 128, 0.1); + box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1); } .stat-item { display: flex; - justify-content: space-between; + flex-direction: column; + justify-content: center; align-items: center; - border-bottom: 1px solid rgba(128, 128, 128, 0.1); - padding: 10px 0; + padding: 12px; + border-radius: 12px; + background: rgba(255, 255, 255, 0.9); + transition: all 0.3s ease; + min-width: 0; + text-align: center; } -.stat-item:last-child { - border-bottom: none; +.stat-item:hover { + background: rgba(108, 92, 231, 0.1); + transform: translateY(-3px); + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); } .stat-val { font-size: 1.5rem; + margin-bottom: 5px; + text-align: center; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + font-weight: bold; } .stat-key { - font-size: 0.8rem; + font-size: 0.75rem; color: var(--text-tertiary); text-transform: uppercase; + text-align: center; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } -/* 访问人数统计样式 */ -#visit-count { - font-family: var(--font-mono); +/* PC端统计区域响应式布局 */ +@media (min-width: 1025px) { + .area-stats { + grid-template-columns: repeat(5, 1fr); + gap: 8px; + } +} + +/* 平板端统计区域布局 */ +@media (min-width: 769px) and (max-width: 1024px) { + .area-stats { + grid-template-columns: repeat(5, 1fr); + gap: 6px; + } + + .stat-item { + padding: 10px 5px; + } + + .stat-val { + font-size: 1.3rem; + } + + .stat-key { + font-size: 0.7rem; + } +} + +/* 移动端统计区域布局 */ +@media (max-width: 768px) { + .area-stats { + grid-template-columns: repeat(5, 1fr); + padding: 15px 10px; + gap: 4px; + } + + .stat-item { + padding: 8px 2px; + } + + .stat-val { + font-size: 1.1rem; + margin-bottom: 3px; + } + + .stat-key { + font-size: 0.6rem; + } } /* --- Mobile Social --- */ @@ -2138,10 +2206,11 @@ body { @media (min-width: 1025px) { .interest-list { display: grid; - grid-template-columns: 1fr; + grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 1rem; } + } .interest-item { background: rgba(128, 128, 128, 0.05); diff --git a/js/about.js b/js/about.js index c1f7138..808def6 100644 --- a/js/about.js +++ b/js/about.js @@ -79,6 +79,8 @@ class I18nManager { "stats.exp": "编程年限", "stats.repos": "开源项目", "stats.followers": "关注者", + "stats.visitors": "访问量", + "stats.visitNum": "访客数", "mbti.name": "提倡者", "mbti.desc": "提倡者人格类型的人非常稀少,只有不到1%的人口属于这种类型,但他们对世界的贡献不容忽视。", "mbti.tag1": "理想主义与道德感", @@ -118,6 +120,8 @@ class I18nManager { "stats.exp": "Years Exp", "stats.repos": "Projects", "stats.followers": "Followers", + "stats.visitors": "Visitors", + "stats.visitNum": "Visiting guests", "mbti.name": "Advocate", "mbti.desc": "Advocates of this personality type are very rare, with less than 1% of the population belonging to this type, but their contributions to the world cannot be ignored.", "mbti.tag1": "Idealism & Morality", @@ -324,7 +328,18 @@ class DataManager { }); } - + formatVisitors() { + const siteVisitorDom = window.document.getElementById('busuanzi_value_site_pv'); + if (siteVisitorDom) { + let count = siteVisitorDom.innerText; + if (count && count.length > 3) { + // 格式化 k,w m等单位 支持两位小数点 + count = count.replace(/(\d)(?=(\d{3})+$)/g, '$1,'); + count = count.replace(/(\d+)(?=(\d{3})+(?:\.\d+)?$)/g, '$0 '); + siteVisitorDom.innerText = count; + } + } + } renderRepos(list) { if (!Array.isArray(list)) list = window.SiteConfig?.defaults?.repos; let html = '';