diff --git a/about.html b/about.html index e7655d0..855206e 100644 --- a/about.html +++ b/about.html @@ -293,9 +293,9 @@ - + + - \ No newline at end of file diff --git a/css/about.css b/css/about.css index 1475095..c73a030 100644 --- a/css/about.css +++ b/css/about.css @@ -1478,6 +1478,55 @@ a:not(.nav-logo):not(.nav-links a):not(.social-link):not(.btn):not(.footer-info font-weight: 500; } +/* 项目描述折叠样式 */ +.project-description.collapsible { + position: relative; + max-height: 100px; + overflow: hidden; +} + +.project-description.collapsible::after { + content: ""; + position: absolute; + bottom: 0; + left: 0; + right: 0; + height: 40px; + background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, var(--glass-alpha))); +} + +.project-description.expanded { + max-height: none; +} + +.project-description.expanded::after { + display: none; +} + +.project-description.collapsible { + position: relative; +} + +.toggle-description { + background: rgba(255, 255, 255, 0.1); + color: var(--text-strong); + border: none; + padding: 0.5rem 1rem; + border-radius: 20px; + cursor: pointer; + font-size: 0.9rem; + margin-top: 1rem; + transition: all 0.3s ease; +} + +.toggle-description:hover { + background: rgba(255, 255, 255, 0.2); +} + +.project-description.collapsible + .toggle-description { + display: inline-block; +} + .project-stats { display: flex; gap: 1rem; diff --git a/index.html b/index.html index ce6f177..0eaa3d8 100644 --- a/index.html +++ b/index.html @@ -42,7 +42,7 @@
- + - Honesty -

+

Copyright © 2018 Honesty

+

Powered By Tencent EdgeOne And Hitokoto @@ -303,8 +303,9 @@ + - + diff --git a/js/about.js b/js/about.js index dec40a6..8bb56bb 100644 --- a/js/about.js +++ b/js/about.js @@ -17,9 +17,9 @@ $(document).ready(function() { // 初始化随机位置 function initRandomPositions() { var cards = $('.social-card'); - var rings = [130, 180, 230]; - var golden = 137.5; - var speedBase = 16; + var rings = SiteConfig.socialCards.rings; + var golden = SiteConfig.socialCards.goldenAngle; + var speedBase = SiteConfig.socialCards.baseSpeed; cards.each(function(idx) { var ring = rings[idx % rings.length]; var angle = (idx * golden) % 360; @@ -76,15 +76,15 @@ function initMotionController() { // GitHub 统计信息 function initGitHubStats() { - var username = 'listener-He'; - var cacheKey = 'github_stats_cache'; - var cacheTimeKey = 'github_stats_cache_time'; + var username = SiteConfig.github.username; + var cacheKey = SiteConfig.github.cache.stats.key; + var cacheTimeKey = SiteConfig.github.cache.stats.timeKey; // 检查缓存(3天有效期) var cachedData = localStorage.getItem(cacheKey); var cacheTime = localStorage.getItem(cacheTimeKey); var now = new Date().getTime(); - var threeDaysInMs = 3 * 24 * 60 * 60 * 1000; // 3天的毫秒数 + var threeDaysInMs = SiteConfig.github.cache.stats.expirationDays * 24 * 60 * 60 * 1000; // 3天的毫秒数 if (cachedData && cacheTime && (now - parseInt(cacheTime)) < threeDaysInMs) { // 使用缓存数据 @@ -115,7 +115,7 @@ function initGitHubStats() { .catch(function() { var fallbackData = { name: 'Honesty', - login: 'listener-He', + login: SiteConfig.github.username, bio: '开发者', avatar_url: 'https://avatars.githubusercontent.com/u/39252579?v=4', public_repos: 0, @@ -160,15 +160,15 @@ function displayGitHubProfile(data) { // 优质项目展示 function initProjects() { - var username = 'listener-He'; - var cacheKey = 'github_projects_cache'; - var cacheTimeKey = 'github_projects_cache_time'; + var username = SiteConfig.github.username; + var cacheKey = SiteConfig.github.cache.projects.key; + var cacheTimeKey = SiteConfig.github.cache.projects.timeKey; // 检查缓存(3天有效期) var cachedData = localStorage.getItem(cacheKey); var cacheTime = localStorage.getItem(cacheTimeKey); var now = new Date().getTime(); - var threeDaysInMs = 3 * 24 * 60 * 60 * 1000; // 3天的毫秒数 + var threeDaysInMs = SiteConfig.github.cache.projects.expirationDays * 24 * 60 * 60 * 1000; // 3天的毫秒数 if (cachedData && cacheTime && (now - parseInt(cacheTime)) < threeDaysInMs) { // 使用缓存数据 @@ -223,13 +223,20 @@ function displayProjects(repos) { (updateDate.getMonth() + 1) + '/' + updateDate.getDate(); + // 处理项目描述,如果超过一定字符数则添加折叠功能 + var description = repo.description || '暂无描述'; + var isLongDescription = description.length > 100; + var displayDescription = isLongDescription ? description.substring(0, 100) + '...' : description; + var descriptionClass = isLongDescription ? 'project-description collapsible' : 'project-description'; + var starSvg = ''; var forkSvg = ''; projectsHtml += '

' + '
' + '
' + '

' + repo.name + '

' + - '

' + (repo.description || '暂无描述') + '

' + + '

' + displayDescription + '

' + + (isLongDescription ? '' : '') + '
' + '
' + '' + starSvg + ' ' + (repo.stargazers_count || 0) + '' + @@ -244,17 +251,36 @@ function displayProjects(repos) { $('#projects-container').html(projectsHtml); } +// 切换项目描述显示状态 +function toggleDescription(event, button) { + event.stopPropagation(); // 阻止事件冒泡,避免触发项目卡片的点击事件 + + var description = button.previousElementSibling; + var fullText = description.getAttribute('data-full-text'); + var shortText = description.getAttribute('data-short-text'); + + if (button.textContent === '显示更多') { + // 展开描述 + description.textContent = fullText; + button.textContent = '收起'; + } else { + // 收起描述 + description.textContent = shortText; + button.textContent = '显示更多'; + } +} + // 博客文章RSS解析 function initBlogArticles() { - var rssUrl = 'https://blog.hehouhui.cn/rss/feed.xml'; - var cacheKey = 'blog_articles_cache'; - var cacheTimeKey = 'blog_articles_cache_time'; + var rssUrl = SiteConfig.blog.rssUrl; + var cacheKey = SiteConfig.blog.cache.key; + var cacheTimeKey = SiteConfig.blog.cache.timeKey; // 检查缓存(3天有效期) var cachedData = localStorage.getItem(cacheKey); var cacheTime = localStorage.getItem(cacheTimeKey); var now = new Date().getTime(); - var threeDaysInMs = 24 * 60 * 60 * 1000; // 1天的毫秒数 + var threeDaysInMs = SiteConfig.blog.cache.expirationDays * 24 * 60 * 60 * 1000; // 1天的毫秒数 if (cachedData && cacheTime && (now - parseInt(cacheTime)) < threeDaysInMs) { // 使用缓存数据 @@ -337,11 +363,11 @@ function initArtalkComments() { el: '#artalk-container', pageKey: window.location.pathname, pageTitle: document.title, - server: 'https://artalk.hehouhui.cn', - site: 'Honesty的主页', - placeholder: '来说点什么吧...', - noComment: '暂无评论', - sendBtn: '发送', + server: SiteConfig.artalk.server, + site: SiteConfig.artalk.site, + placeholder: SiteConfig.artalk.placeholder, + noComment: SiteConfig.artalk.noComment, + sendBtn: SiteConfig.artalk.sendBtn, darkMode: false, gravatar: { mirror: 'https://cravatar.cn/avatar/' }, pagination: { pageSize: 20, readMore: true, autoLoad: true }, @@ -366,46 +392,7 @@ function renderCommentsFallback(msg) { // 技术云图初始化 function initTechCloud() { // 技术栈数据 - var techStack = [ - { name: 'Java', category: 'core', weight: 5 }, - { name: 'Spring Boot', category: 'backend', weight: 5 }, - { name: 'JavaScript', category: 'core', weight: 5 }, - { name: 'Python', category: 'core', weight: 4 }, - { name: 'WebFlux', category: 'backend', weight: 5 }, - { name: 'Reactor', category: 'backend', weight: 5 }, - { name: 'TypeScript', category: 'core', weight: 4 }, - { name: 'Spring Cloud', category: 'backend', weight: 4 }, - { name: 'Go', category: 'core', weight: 3 }, - { name: 'MySQL', category: 'data', weight: 4 }, - { name: 'Redis', category: 'data', weight: 4 }, - { name: 'MongoDB', category: 'data', weight: 3 }, - { name: 'Docker', category: 'ops', weight: 4 }, - { name: 'Kubernetes', category: 'ops', weight: 3 }, - { name: 'OpenAI API', category: 'ai', weight: 3 }, - { name: 'LangChain', category: 'ai', weight: 3 }, - { name: 'TensorFlow', category: 'ai', weight: 2 }, - { name: 'PyTorch', category: 'ai', weight: 2 }, - { name: 'Elasticsearch', category: 'data', weight: 3 }, - { name: 'RabbitMQ', category: 'data', weight: 2 }, - { name: 'Kafka', category: 'data', weight: 2 }, - { name: 'Jenkins', category: 'ops', weight: 3 }, - { name: 'Git', category: 'ops', weight: 4 }, - { name: 'Linux', category: 'ops', weight: 3 }, - { name: 'AWS', category: 'ops', weight: 2 }, - { name: 'Nginx', category: 'ops', weight: 2 }, - { name: 'Spring Security', category: 'backend', weight: 3 }, - { name: 'MyBatis', category: 'backend', weight: 3 }, - { name: 'JPA', category: 'backend', weight: 2 }, - { name: 'Dubbo', category: 'backend', weight: 2 }, - { name: 'Netty', category: 'backend', weight: 2 }, - { name: 'Transformers', category: 'ai', weight: 2 }, - { name: 'Scikit-learn', category: 'ai', weight: 2 }, - { name: 'Ollama', category: 'ai', weight: 1 }, - { name: 'Dify', category: 'ai', weight: 1 }, - { name: 'Spring AI', category: 'ai', weight: 1 }, - { name: 'ClickHouse', category: 'data', weight: 1 }, - { name: 'Postgresql', category: 'data', weight: 1 } - ]; + var techStack = SiteConfig.techStack; var reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches; var isMobile = window.matchMedia('(pointer: coarse)').matches || window.innerWidth <= 768; @@ -1017,11 +1004,12 @@ function updateTechTagColors() { } }); } + function initCommitStats(username) { - var cacheKey = 'github_commits_cache'; - var cacheTimeKey = 'github_commits_cache_time'; + var cacheKey = SiteConfig.github.cache.commits.key; + var cacheTimeKey = SiteConfig.github.cache.commits.timeKey; var now = new Date().getTime(); - var oneDay = 24 * 60 * 60 * 1000; + var oneDay = SiteConfig.github.cache.commits.expirationHours * 60 * 60 * 1000; var cached = localStorage.getItem(cacheKey); var cachedTime = localStorage.getItem(cacheTimeKey); if (cached && cachedTime && (now - parseInt(cachedTime)) < oneDay) { diff --git a/js/bj.js b/js/bj.js index 9ad16b8..d80417a 100644 --- a/js/bj.js +++ b/js/bj.js @@ -3,7 +3,7 @@ var stars_count; var stars; ini(); makeStars(); -var interval=setInterval(function(){drawStars();},50);//��ʱˢ���������� +var interval; function ini(){//初始化 canvas = document.getElementById("bg"); @@ -14,12 +14,16 @@ function ini(){//初始化 canvas.width = window.innerWidth; canvas.height = window.innerHeight; context = canvas.getContext("2d"); - stars = Array();//������������ɵ��������ݣ�x,y,��С����ɫ���ٶȣ� - stars_count = 300;//�������� - clearInterval(interval); + stars = Array();//ɵݣx,y,Сɫٶȣ + stars_count = SiteConfig.stars.count;// + + // 清除可能存在的旧interval + if (interval) { + clearInterval(interval); + } } -function makeStars(){//��������������� +function makeStars(){// if (!canvas) return; for(var i=0;i -1 || location.hostname.indexOf( '127.0.0.1') > -1 + } +}; + +// 导出配置 +if (typeof module !== 'undefined' && module.exports) { + module.exports = SiteConfig; +} else if (typeof window !== 'undefined') { + window.SiteConfig = SiteConfig; +} \ No newline at end of file diff --git a/js/main.js b/js/main.js index 901af07..e2c74ec 100644 --- a/js/main.js +++ b/js/main.js @@ -30,12 +30,20 @@ var iUp = (function () { $(document).ready(function () { // 获取一言数据 - fetch('https://v1.hitokoto.cn?c=c&c=d&c=i&c=k').then(function (res) { + // 检查是否在本地开发环境 + var isLocal = location.hostname === 'localhost' || location.hostname === '127.0.0.1'; + var hitokotoUrl = isLocal ? 'https://v1.hitokoto.cn/' : SiteConfig.hitokoto.apiUrl; + + fetch(hitokotoUrl).then(function (res) { return res.json(); }).then(function (e) { $('#description').html(e.hitokoto + "
-「" + e.from + "」") }).catch(function (err) { console.error("获取一言数据失败", err); + // 本地开发环境使用默认文本 + if (isLocal) { + $('#description').html('人生天地之间,若白驹之过隙,忽然而已。
-「Honesty」'); + } }) /** @@ -49,9 +57,9 @@ $(document).ready(function () { if (imgUrls == null) { imgUrls = []; index = 0; - for (let i = 1; i < 8; i++) { - imgUrls.push("/images/bj/"+i+".jpg"); - } + SiteConfig.background.imagePaths.forEach(path => { + imgUrls.push(path); + }); sessionStorage.setItem("imgUrls", JSON.stringify(imgUrls)); // sessionStorage.setItem("index", index); } else { @@ -87,6 +95,4 @@ $('.btn-mobile-menu__icon').click(function () { $('.navigation-wrapper').toggleClass('visible animated bounceInDown'); } $('.btn-mobile-menu__icon').toggleClass('social iconfont icon-list social iconfont icon-ngleup animated fadeIn'); -}); - - +}); \ No newline at end of file