站内搜索优化
This commit is contained in:
parent
a762cea444
commit
d96d550776
@ -8,6 +8,7 @@ new Vue({
|
|||||||
searchResult: []
|
searchResult: []
|
||||||
},
|
},
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
|
resultDiv = document.getElementById("search-result-box")
|
||||||
axios({
|
axios({
|
||||||
url: "/search.xml"
|
url: "/search.xml"
|
||||||
}).then(function(response){
|
}).then(function(response){
|
||||||
@ -28,7 +29,6 @@ new Vue({
|
|||||||
url: item.getElementsByTagName("url")[0].textContent,
|
url: item.getElementsByTagName("url")[0].textContent,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
resultDiv = document.getElementById("search-result-box")
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -69,14 +69,12 @@ new Vue({
|
|||||||
resultItem.url = article.url;
|
resultItem.url = article.url;
|
||||||
resultItem.title = article.title;
|
resultItem.title = article.title;
|
||||||
if (first_occur >= 0) {
|
if (first_occur >= 0) {
|
||||||
// cut out characters
|
// 截取出关键字所在的前后若干字符
|
||||||
var start = first_occur - 6;
|
var start = first_occur - 10;
|
||||||
var end = first_occur + 15;
|
var end = first_occur + 15;
|
||||||
if(start < 0){
|
if(start <= 0){
|
||||||
start = 0;
|
start = 0;
|
||||||
}
|
end = 25;
|
||||||
if(start == 0){
|
|
||||||
end = 10;
|
|
||||||
}
|
}
|
||||||
if(end > content.length){
|
if(end > content.length){
|
||||||
end = content.length;
|
end = content.length;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user