From 23eab42bd7c7d3da6814c81d17ce80aba6c1d5ae Mon Sep 17 00:00:00 2001 From: Vaica <94612053+zqlit@users.noreply.github.com> Date: Sat, 31 Jan 2026 19:24:22 +0800 Subject: [PATCH] fixed bug --- content/about.md | 75 - hugo.toml | 7 + themes/Ying/assets/css/main.css | 200 ++- themes/Ying/assets/js/EasyLazyload.min.js | 97 -- themes/Ying/assets/js/main.js | 204 +-- themes/Ying/assets/js/modules/artalk.js | 93 ++ .../Ying/assets/js/modules/floating-tools.js | 106 ++ themes/Ying/assets/js/modules/lazyload.js | 88 ++ themes/Ying/assets/js/modules/loader.js | 17 + themes/Ying/assets/js/modules/search.js | 196 +++ themes/Ying/assets/js/modules/utils.js | 8 + themes/Ying/assets/js/mypjax.js | 107 +- themes/Ying/assets/js/pjax.js | 1252 +++++++++++++++++ themes/Ying/layouts/_default/about.html | 25 +- themes/Ying/layouts/categories/term.html | 2 +- themes/Ying/layouts/partials/footer.html | 12 +- themes/Ying/layouts/partials/head.html | 3 +- themes/Ying/layouts/partials/heatmap.html | 200 +++ themes/Ying/layouts/partials/skills.html | 68 + themes/Ying/static/js/jquery.min.js | 4 - themes/Ying/static/js/jquery.scrollUp.min.js | 7 - 21 files changed, 2363 insertions(+), 408 deletions(-) delete mode 100644 themes/Ying/assets/js/EasyLazyload.min.js create mode 100644 themes/Ying/assets/js/modules/artalk.js create mode 100644 themes/Ying/assets/js/modules/floating-tools.js create mode 100644 themes/Ying/assets/js/modules/lazyload.js create mode 100644 themes/Ying/assets/js/modules/loader.js create mode 100644 themes/Ying/assets/js/modules/search.js create mode 100644 themes/Ying/assets/js/modules/utils.js create mode 100644 themes/Ying/assets/js/pjax.js create mode 100644 themes/Ying/layouts/partials/heatmap.html create mode 100644 themes/Ying/layouts/partials/skills.html delete mode 100644 themes/Ying/static/js/jquery.min.js delete mode 100644 themes/Ying/static/js/jquery.scrollUp.min.js diff --git a/content/about.md b/content/about.md index ce2698aa..ec4d26e7 100644 --- a/content/about.md +++ b/content/about.md @@ -32,78 +32,3 @@ draft: false - -
输入关键词并回车进行搜索
'; + return; + } + + var results = window.searchIndex.filter(function(item) { + return (item.title && item.title.toLowerCase().includes(query)) || + (item.summary && item.summary.toLowerCase().includes(query)); + }); + + if (results.length > 0) { + var html = results.map(function(item) { + return ` + + `; + }).join(''); + searchResults.innerHTML = html; + + // Refresh PJAX to recognize new links + if (window.pjax) { + window.pjax.refresh(searchResults); + } + } else { + searchResults.innerHTML = '未找到相关文章
'; + } + }); + } + } +} + +function initInlineSearch() { + var header = document.getElementById('essay-header'); + var searchContainer = document.getElementById('search-container'); + var input = document.getElementById('inline-search-input'); + var resultsContainer = document.getElementById('inline-search-results'); + + window.toggleSearchMode = function(show) { + if (!header || !searchContainer || !input || !resultsContainer) return; + + if (show) { + header.style.display = 'none'; + searchContainer.style.display = 'block'; + input.focus(); + loadSearchIndex(); + } else { + header.style.display = 'inline-flex'; + searchContainer.style.display = 'none'; + input.value = ''; + resultsContainer.classList.remove('show'); + resultsContainer.innerHTML = ''; + } + }; + + if (!header || !searchContainer || !input || !resultsContainer) return; + + // Input Event + var newInput = input.cloneNode(true); + input.parentNode.replaceChild(newInput, input); + input = newInput; + + input.addEventListener('input', function() { + var query = this.value.trim().toLowerCase(); + + if (query.length === 0) { + resultsContainer.classList.remove('show'); + resultsContainer.innerHTML = ''; + return; + } + + if (!window.searchIndex) return; + + var results = window.searchIndex.filter(function(item) { + return (item.title && item.title.toLowerCase().includes(query)) || + (item.summary && item.summary.toLowerCase().includes(query)); + }); + + if (results.length > 0) { + var html = results.slice(0, 5).map(function(item) { + return ` + + ${item.title} +