From d96d550776deb924a6cfbbae49edd9f62bfb4279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BB=93=E5=8F=91=E5=8F=97=E9=95=BF=E7=94=9F?= Date: Wed, 16 May 2018 16:51:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=99=E5=86=85=E6=90=9C=E7=B4=A2=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo-theme-xups/source/js/local-search.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/themes/hexo-theme-xups/source/js/local-search.js b/themes/hexo-theme-xups/source/js/local-search.js index 1c55f95..5c5171b 100644 --- a/themes/hexo-theme-xups/source/js/local-search.js +++ b/themes/hexo-theme-xups/source/js/local-search.js @@ -8,6 +8,7 @@ new Vue({ searchResult: [] }, mounted: function() { + resultDiv = document.getElementById("search-result-box") axios({ url: "/search.xml" }).then(function(response){ @@ -28,7 +29,6 @@ new Vue({ url: item.getElementsByTagName("url")[0].textContent, } }) - resultDiv = document.getElementById("search-result-box") }); }, watch: { @@ -69,14 +69,12 @@ new Vue({ resultItem.url = article.url; resultItem.title = article.title; if (first_occur >= 0) { - // cut out characters - var start = first_occur - 6; + // 截取出关键字所在的前后若干字符 + var start = first_occur - 10; var end = first_occur + 15; - if(start < 0){ + if(start <= 0){ start = 0; - } - if(start == 0){ - end = 10; + end = 25; } if(end > content.length){ end = content.length;