From c45274a52cfce595627d1e253ee62338b0f938eb Mon Sep 17 00:00:00 2001 From: hehh Date: Sun, 23 Nov 2025 16:59:02 +0800 Subject: [PATCH] =?UTF-8?q?feat(about):=20=E4=BC=98=E5=8C=96=E6=8A=80?= =?UTF-8?q?=E6=9C=AF=E4=BA=91=E6=B8=B2=E6=9F=93=E5=92=8C=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 CSS `will-change` 属性提升动画性能 - 支持自定义 GitHub 和博客缓存键配置 - 技术标签云支持窗口大小变化时重新初始化 - 为 3D 标签球添加动画防抖标识防止重复执行 - 优化标签位置更新逻辑确保动画同步 - 移除冗余的博客缓存时间键配置项 --- css/about.css | 1 + js/about.js | 14 +++++++++++--- js/config.js | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/css/about.css b/css/about.css index c0d0925..d6412e5 100644 --- a/css/about.css +++ b/css/about.css @@ -271,6 +271,7 @@ body { user-select: none; white-space: nowrap; backface-visibility: hidden; + will-change: transform; /* 移除背景色和边框,只保留文字渐变效果 */ background: none; border: none; diff --git a/js/about.js b/js/about.js index e59b0de..67f3a35 100644 --- a/js/about.js +++ b/js/about.js @@ -142,7 +142,7 @@ class DataManager { // 优先缓存 -> API -> 默认值 async fetchGithub() { const user = (window.SiteConfig?.github?.username) || 'listener-He'; - const cacheKey = 'gh_data_v2'; + const cacheKey = (window.SiteConfig?.github?.cache?.cacheKey) || 'gh_data_v2'; const cached = JSON.parse(localStorage.getItem(cacheKey)); const now = Date.now(); @@ -220,7 +220,7 @@ class DataManager { // 从RSS获取博客文章 async fetchBlog() { const rssUrl = window.SiteConfig?.blog?.rssUrl || 'https://blog.hehouhui.cn/api/rss'; - const cacheKey = 'blog_data_v2'; + const cacheKey = window.SiteConfig?.blog?.cache?.key || 'blog_data_v2'; const cached = JSON.parse(localStorage.getItem(cacheKey)); const now = Date.now(); @@ -332,6 +332,11 @@ class UIManager { this.initTechCloud(); this.initModal(); this.initArtalk(); + let resizeTimer = null; + window.addEventListener('resize', () => { + clearTimeout(resizeTimer); + resizeTimer = setTimeout(() => this.initTechCloud(), 150); + }); } initModal() { @@ -392,6 +397,8 @@ class UIManager { } else { // PC: 3D Sphere container.classList.remove('mobile-scroll'); + const token = Date.now(); + container.__animToken = token; const tags = []; techStack.forEach((item, index) => { @@ -431,6 +438,7 @@ class UIManager { }; const update = () => { + if (container.__animToken !== token) return; let a, b; if(active) { a = (-Math.min(Math.max(-mouseY, -200), 200)/radius) * 2 + autoAx; @@ -458,7 +466,7 @@ class UIManager { let top = tag.y + container.offsetHeight/2 - tag.el.offsetHeight/2; tag.el.style.transform = `translate(${left}px, ${top}px) scale(${scale})`; }); - requestAnimationFrame(update); + container.__animId = requestAnimationFrame(update); }; update(); } diff --git a/js/config.js b/js/config.js index ba25f17..e3b15ed 100644 --- a/js/config.js +++ b/js/config.js @@ -36,6 +36,7 @@ const SiteConfig = { github: { username: 'listener-He', cache: { + cacheKey: "gh_data_v2", stats: { key: 'github_stats_cache', timeKey: 'github_stats_cache_time', @@ -58,7 +59,6 @@ const SiteConfig = { rssUrl: 'https://blog.hehouhui.cn/api/rss', cache: { key: 'blog_articles_cache', - timeKey: 'blog_articles_cache_time', expirationDays: 1 } },