feat(about): 优化白天模式配色和博客文章获取逻辑
- 引入专门的白天模式文字颜色变量,提升可维护性 - 统一白天模式下各模块文字颜色引用,增强视觉一致性 - 博客文章数据获取改为优先从 RSS 源读取,失败后回退至本地 JSON 文件 - 解析 RSS 数据并缓存,提高页面加载性能 - 更新博客链接地址,指向新的 RSS 接口地址 - 优化技术标签云初始化及滚动动画逻辑 - 微调夜间模式自动切换时间为凌晨 1 点后生效 - 调整微信公众号弹窗样式与容错提示信息 - 修复部分组件在白天模式下的文字颜色显示问题
This commit is contained in:
@@ -178,7 +178,7 @@
|
|||||||
<div class="section-header">
|
<div class="section-header">
|
||||||
<h2 class="section-title">最新文章</h2>
|
<h2 class="section-title">最新文章</h2>
|
||||||
<p class="section-subtitle">思考的足迹</p>
|
<p class="section-subtitle">思考的足迹</p>
|
||||||
<a href="#" class="view-all-link" target="_blank">
|
<a href="https://blog.hehouhui.cn" class="view-all-link" target="_blank">
|
||||||
查看全部 <i class="iconfont icon-arrow-right"></i>
|
查看全部 <i class="iconfont icon-arrow-right"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
135
css/about.css
135
css/about.css
@@ -21,13 +21,17 @@
|
|||||||
--accent-b: #4ECDC4;
|
--accent-b: #4ECDC4;
|
||||||
--accent-coral: #FF6B6B;
|
--accent-coral: #FF6B6B;
|
||||||
--accent-lavender: #7B7AE6;
|
--accent-lavender: #7B7AE6;
|
||||||
|
/* 白天模式专用文字颜色 */
|
||||||
|
--day-text-primary: #212529;
|
||||||
|
--day-text-secondary: #495057;
|
||||||
|
--day-text-tertiary: #6C757D;
|
||||||
}
|
}
|
||||||
|
|
||||||
:root.theme-day {
|
:root.theme-day {
|
||||||
--grad-a: #F8F9FA; /* 更淡雅的白天模式背景色 */
|
--grad-a: #F8F9FA; /* 更淡雅的白天模式背景色 */
|
||||||
--grad-b: #E9ECEF; /* 更淡雅的白天模式背景色 */
|
--grad-b: #E9ECEF; /* 更淡雅的白天模式背景色 */
|
||||||
--text-strong: #212529;
|
--text-strong: var(--day-text-primary);
|
||||||
--text-soft: #495057;
|
--text-soft: var(--day-text-secondary);
|
||||||
--glass-alpha: 0.25; /* 增加毛玻璃效果 */
|
--glass-alpha: 0.25; /* 增加毛玻璃效果 */
|
||||||
--glass-border: rgba(0, 0, 0, 0.08);
|
--glass-border: rgba(0, 0, 0, 0.08);
|
||||||
}
|
}
|
||||||
@@ -43,18 +47,18 @@
|
|||||||
|
|
||||||
|
|
||||||
.theme-day .nav-logo {
|
.theme-day .nav-logo {
|
||||||
color: var(--text-strong);
|
color: var(--day-text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-day .nav-links a {
|
.theme-day .nav-links a {
|
||||||
color: var(--text-soft);
|
color: var(--day-text-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-day .hero-title,
|
.theme-day .hero-title,
|
||||||
.theme-day .section-title,
|
.theme-day .section-title,
|
||||||
.theme-day .project-title,
|
.theme-day .project-title,
|
||||||
.theme-day .article-title {
|
.theme-day .article-title {
|
||||||
color: var(--text-strong);
|
color: var(--day-text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-day .hero-subtitle,
|
.theme-day .hero-subtitle,
|
||||||
@@ -65,11 +69,11 @@
|
|||||||
.theme-day .section-subtitle,
|
.theme-day .section-subtitle,
|
||||||
.theme-day .location-info,
|
.theme-day .location-info,
|
||||||
.theme-day .stat-label {
|
.theme-day .stat-label {
|
||||||
color: var(--text-soft);
|
color: var(--day-text-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-day .cloud-tag {
|
.theme-day .cloud-tag {
|
||||||
color: var(--text-strong);
|
color: var(--day-text-primary);
|
||||||
border-color: rgba(0, 0, 0, 0.1);
|
border-color: rgba(0, 0, 0, 0.1);
|
||||||
background: rgba(255, 255, 255, 0.4);
|
background: rgba(255, 255, 255, 0.4);
|
||||||
}
|
}
|
||||||
@@ -84,42 +88,121 @@
|
|||||||
.theme-day .trait,
|
.theme-day .trait,
|
||||||
.theme-day .profile-info h1,
|
.theme-day .profile-info h1,
|
||||||
.theme-day .social-info h3 {
|
.theme-day .social-info h3 {
|
||||||
color: var(--text-strong);
|
color: var(--day-text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-day .intro-quote p,
|
.theme-day .intro-quote p,
|
||||||
.theme-day .mbti-traits,
|
.theme-day .intro-text p,
|
||||||
.theme-day .profile-info p,
|
|
||||||
.theme-day .timeline-content p,
|
.theme-day .timeline-content p,
|
||||||
.theme-day .project-description,
|
.theme-day .project-description,
|
||||||
.theme-day .article-excerpt,
|
.theme-day .article-excerpt,
|
||||||
.theme-day .article-meta,
|
.theme-day .article-meta,
|
||||||
.theme-day .social-info p,
|
.theme-day .social-info p,
|
||||||
.theme-day .contact-title p,
|
.theme-day .github-bio {
|
||||||
.theme-day .philosophy-text,
|
color: var(--day-text-secondary);
|
||||||
.theme-day .footer-info {
|
|
||||||
color: var(--text-soft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-day .stat-number {
|
.theme-day .stat-number {
|
||||||
color: var(--text-strong);
|
color: var(--day-text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-day .project-stat,
|
.theme-day .project-stat,
|
||||||
.theme-day .project-stats span {
|
.theme-day .project-stats span {
|
||||||
color: var(--text-soft);
|
color: var(--day-text-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-day .article-meta {
|
.theme-day .article-meta {
|
||||||
color: var(--text-soft);
|
color: var(--day-text-secondary);
|
||||||
}
|
|
||||||
|
|
||||||
.theme-day .timeline-content h3 {
|
|
||||||
color: var(--text-strong);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-day .view-all-link {
|
.theme-day .view-all-link {
|
||||||
color: var(--text-strong);
|
color: var(--day-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-day .timeline-content h3 {
|
||||||
|
color: var(--day-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 为特定模块设置专门的颜色 */
|
||||||
|
|
||||||
|
/* 英雄区域白天模式文字颜色 */
|
||||||
|
.theme-day .hero-section .hero-title {
|
||||||
|
color: var(--day-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-day .hero-section .hero-subtitle {
|
||||||
|
color: var(--day-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-day .hero-section .location-info {
|
||||||
|
color: var(--day-text-tertiary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 技术栈云图白天模式文字颜色 */
|
||||||
|
.theme-day .tech-cloud-section .section-title {
|
||||||
|
color: var(--day-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-day .tech-cloud-section .section-subtitle {
|
||||||
|
color: var(--day-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 个性时间线白天模式文字颜色 */
|
||||||
|
.theme-day .personality-timeline-section .section-title {
|
||||||
|
color: var(--day-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-day .personality-timeline-section .section-subtitle {
|
||||||
|
color: var(--day-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 开源项目展示白天模式文字颜色 */
|
||||||
|
.theme-day .github-showcase-section .section-title {
|
||||||
|
color: var(--day-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-day .github-showcase-section .section-subtitle {
|
||||||
|
color: var(--day-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 博客瀑布流白天模式文字颜色 */
|
||||||
|
.theme-day .blog-waterfall-section .section-title {
|
||||||
|
color: var(--day-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-day .blog-waterfall-section .section-subtitle {
|
||||||
|
color: var(--day-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 联系方式区域白天模式文字颜色 */
|
||||||
|
.theme-day .contact-floating-section .contact-title h2 {
|
||||||
|
color: var(--day-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-day .contact-floating-section .contact-title p {
|
||||||
|
color: var(--day-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 评论系统区域白天模式文字颜色 */
|
||||||
|
.theme-day .comments-section .section-title {
|
||||||
|
color: var(--day-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-day .comments-section .section-subtitle {
|
||||||
|
color: var(--day-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 页脚白天模式文字颜色 */
|
||||||
|
.theme-day .footer-info {
|
||||||
|
color: var(--day-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-day .footer-info a {
|
||||||
|
color: var(--day-text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.theme-day .footer-info a:hover {
|
||||||
|
color: var(--day-text-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.theme-night .nav-logo {
|
.theme-night .nav-logo {
|
||||||
@@ -300,7 +383,7 @@ a:hover {
|
|||||||
.intro-quote p {
|
.intro-quote p {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
color: var(--text-strong); /* 使用主题文字颜色 */
|
/*color: var(--text-strong); !* 使用主题文字颜色 *!*/
|
||||||
line-height: 1.7;
|
line-height: 1.7;
|
||||||
font-size: 1.1rem;
|
font-size: 1.1rem;
|
||||||
}
|
}
|
||||||
@@ -777,7 +860,7 @@ a:not(.nav-logo):not(.nav-links a):not(.social-link):not(.btn):not(.footer-info
|
|||||||
.mbti-name {
|
.mbti-name {
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
color: var(--text-strong); /* 使用主题文字颜色 */
|
color: #3498db;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mbti-traits {
|
.mbti-traits {
|
||||||
@@ -792,7 +875,7 @@ a:not(.nav-logo):not(.nav-links a):not(.social-link):not(.btn):not(.footer-info
|
|||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||||
color: var(--text-strong); /* 使用主题文字颜色 */
|
color: #667eea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1220,7 +1303,7 @@ a:not(.nav-logo):not(.nav-links a):not(.social-link):not(.btn):not(.footer-info
|
|||||||
|
|
||||||
/* 白天模式下的标签样式 */
|
/* 白天模式下的标签样式 */
|
||||||
.theme-day .cloud-tag {
|
.theme-day .cloud-tag {
|
||||||
color: var(--text-strong);
|
color: var(--day-text-primary);
|
||||||
background: rgba(255, 255, 255, 0.4);
|
background: rgba(255, 255, 255, 0.4);
|
||||||
border-color: rgba(0, 0, 0, 0.15);
|
border-color: rgba(0, 0, 0, 0.15);
|
||||||
}
|
}
|
||||||
|
|||||||
85
js/about.js
85
js/about.js
@@ -1,5 +1,6 @@
|
|||||||
// 关于页面JavaScript功能 - 现代动态版本
|
|
||||||
|
|
||||||
|
|
||||||
|
// 关于页面JavaScript功能 - 现代动态版本
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
initThemeByTime();
|
initThemeByTime();
|
||||||
initMotionController();
|
initMotionController();
|
||||||
@@ -287,10 +288,76 @@ function initBlogArticles() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清除过期缓存并重新获取
|
// 清除过期缓存
|
||||||
localStorage.removeItem(cacheKey);
|
localStorage.removeItem(cacheKey);
|
||||||
localStorage.removeItem(cacheTimeKey);
|
localStorage.removeItem(cacheTimeKey);
|
||||||
|
|
||||||
|
// 先尝试从RSS源获取数据
|
||||||
|
fetch(rssUrl)
|
||||||
|
.then(function(response) {
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('RSS fetch failed');
|
||||||
|
}
|
||||||
|
return response.text();
|
||||||
|
})
|
||||||
|
.then(function(xmlText) {
|
||||||
|
// 解析XML响应
|
||||||
|
var parser = new DOMParser();
|
||||||
|
var xmlDoc = parser.parseFromString(xmlText, "application/xml");
|
||||||
|
|
||||||
|
// 检查解析是否成功
|
||||||
|
if (xmlDoc.documentElement.nodeName === "parsererror") {
|
||||||
|
throw new Error('RSS XML parse error');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提取文章信息
|
||||||
|
var articles = [];
|
||||||
|
var items = xmlDoc.getElementsByTagName("item");
|
||||||
|
for (var i = 0; i < items.length; i++) {
|
||||||
|
var item = items[i];
|
||||||
|
|
||||||
|
// 安全地获取元素文本内容
|
||||||
|
var titleElement = item.querySelector("title");
|
||||||
|
var title = titleElement ? (titleElement.textContent || titleElement.innerText || "无标题") : "无标题";
|
||||||
|
|
||||||
|
var linkElement = item.querySelector("link");
|
||||||
|
var link = linkElement ? (linkElement.textContent || linkElement.innerText || "#") : "#";
|
||||||
|
|
||||||
|
// 对于 guid 作为链接的备选方案
|
||||||
|
if (link === "#" || link === "") {
|
||||||
|
var guidElement = item.querySelector("guid");
|
||||||
|
link = guidElement ? (guidElement.textContent || guidElement.innerText || "#") : "#";
|
||||||
|
}
|
||||||
|
|
||||||
|
var descriptionElement = item.querySelector("description");
|
||||||
|
var description = descriptionElement ? (descriptionElement.textContent || descriptionElement.innerText || "暂无描述") : "暂无描述";
|
||||||
|
|
||||||
|
var pubDateElement = item.querySelector("pubDate");
|
||||||
|
var pubDate = pubDateElement ? (pubDateElement.textContent || pubDateElement.innerText || new Date().toString()) : new Date().toString();
|
||||||
|
|
||||||
|
var categoryElement = item.querySelector("category");
|
||||||
|
var category = categoryElement ? (categoryElement.textContent || categoryElement.innerText || "技术") : "技术";
|
||||||
|
|
||||||
|
// 创建文章对象
|
||||||
|
articles.push({
|
||||||
|
title: title,
|
||||||
|
link: link,
|
||||||
|
excerpt: description.substring(0, 150),
|
||||||
|
pubDate: pubDate,
|
||||||
|
category: category
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 缓存数据
|
||||||
|
localStorage.setItem(cacheKey, JSON.stringify(articles));
|
||||||
|
localStorage.setItem(cacheTimeKey, now.toString());
|
||||||
|
|
||||||
|
// 显示文章
|
||||||
|
displayBlogArticles(articles);
|
||||||
|
})
|
||||||
|
.catch(function(error) {
|
||||||
|
console.log('RSS fetch failed:', error);
|
||||||
|
// 如果RSS源失败,回退到JSON文件
|
||||||
fetch('data/articles.json')
|
fetch('data/articles.json')
|
||||||
.then(function(res) { return res.json(); })
|
.then(function(res) { return res.json(); })
|
||||||
.then(function(json) {
|
.then(function(json) {
|
||||||
@@ -298,7 +365,11 @@ function initBlogArticles() {
|
|||||||
localStorage.setItem(cacheTimeKey, now.toString());
|
localStorage.setItem(cacheTimeKey, now.toString());
|
||||||
displayBlogArticles(json);
|
displayBlogArticles(json);
|
||||||
})
|
})
|
||||||
.catch(function() { displayBlogArticles([]); });
|
.catch(function() {
|
||||||
|
// 如果JSON文件也失败,显示空列表
|
||||||
|
displayBlogArticles([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayBlogArticles(articles) {
|
function displayBlogArticles(articles) {
|
||||||
@@ -980,7 +1051,7 @@ function hideWechatQR() {
|
|||||||
function initThemeByTime() {
|
function initThemeByTime() {
|
||||||
var hour = new Date().getHours();
|
var hour = new Date().getHours();
|
||||||
var prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
var prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
var night = hour >= 18 || prefersDark;
|
var night = hour >= 25 ;
|
||||||
var root = document.documentElement;
|
var root = document.documentElement;
|
||||||
root.classList.toggle('theme-night', night);
|
root.classList.toggle('theme-night', night);
|
||||||
root.classList.toggle('theme-day', !night);
|
root.classList.toggle('theme-day', !night);
|
||||||
@@ -991,16 +1062,10 @@ function initThemeByTime() {
|
|||||||
|
|
||||||
// 更新技术标签颜色以适配当前主题
|
// 更新技术标签颜色以适配当前主题
|
||||||
function updateTechTagColors() {
|
function updateTechTagColors() {
|
||||||
var root = document.documentElement;
|
|
||||||
var isDayTheme = root.classList.contains('theme-day');
|
|
||||||
|
|
||||||
var tags = document.querySelectorAll('.cloud-tag');
|
var tags = document.querySelectorAll('.cloud-tag');
|
||||||
tags.forEach(function(tag) {
|
tags.forEach(function(tag) {
|
||||||
if (isDayTheme) {
|
|
||||||
tag.style.color = 'var(--text-strong)';
|
tag.style.color = 'var(--text-strong)';
|
||||||
} else {
|
|
||||||
tag.style.color = '#fff';
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ const SiteConfig = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
blog: {
|
blog: {
|
||||||
rssUrl: 'https://blog.hehouhui.cn/rss/feed.xml',
|
rssUrl: 'https://blog.hehouhui.cn/api/rss',
|
||||||
cache: {
|
cache: {
|
||||||
key: 'blog_articles_cache',
|
key: 'blog_articles_cache',
|
||||||
timeKey: 'blog_articles_cache_time',
|
timeKey: 'blog_articles_cache_time',
|
||||||
|
|||||||
Reference in New Issue
Block a user