mirror of
https://ghfast.top/https://github.com/zsjy/halo-theme-dream2.0-plus.git
synced 2025-03-16 04:19:41 +08:00
更改搜索功能
This commit is contained in:
parent
3e3132d9eb
commit
df8c7589d7
@ -88,4 +88,4 @@ $(function () {
|
|||||||
var event = new Event('input', {bubbles: true})
|
var event = new Event('input', {bubbles: true})
|
||||||
searchInput.dispatchEvent(event)
|
searchInput.dispatchEvent(event)
|
||||||
}
|
}
|
||||||
})()
|
})
|
2
templates/assets/js/search.min.js
vendored
2
templates/assets/js/search.min.js
vendored
@ -1 +1 @@
|
|||||||
$(function(){var e,t=document.getElementById("dream-search-form"),a=DreamConfig.search_target,n=document.getElementById("halo-search-form-text-input"),i=$("#dream-search-result"),r=$("#dream-search-result-empty");function s(e){return e.replace(/<(?!(?:mark\b[^<>]*)<\/mark>|mark\b)[^<>]*>/gi,"")}function c(e){if(!e)return i.empty(),r.show();Utils.request({url:"/apis/api.halo.run/v1alpha1/indices/post",contentType:"application/json;charset=UTF-8",returnRaw:!0,data:{keyword:e,limit:$("#halo-search-form-limit").val(),highlightPreTag:"<mark>",highlightPostTag:"</mark>"}}).then(e=>{if(console.log(e),0<e.hits.length){r.hide(),i.empty();for(var t=0;t<e.hits.length;t++){var n=e.hits[t];i.append('<div class="widget card search">\n<div class="card-content main">\n<a href="'+n.permalink+'" target="'+a+'">\n<h2 class="title">'+s(n.title)+'</h2>\n</a>\n<div class="main-content not-toc description">\n'+s(n.description)+'\n</div>\n<hr/>\n<div class="meta">\n<div></div>\n<em text="最后更新于 '+Utils.formatDate(n.updateTimestamp,"yyyy年MM月dd日 HH:mm:ss")+'"></em>\n</div>\n</div>\n')}}else r.show(),i.empty()}).catch(e=>{})}t.addEventListener("submit",function(e){e.preventDefault(),c(n.value)}),document.addEventListener("keydown",function(e){"Enter"===e.key&&t.contains(document.activeElement)&&(e.preventDefault(),c(n.value))}),n.addEventListener("input",function(e){c(e.target.value)}),function(e,t=window.location.href){e="keyword".replace(/[\[\]]/g,"\\$&");e=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return e&&e[2]&&decodeURIComponent(e[2].replace(/\+/g," "))}()&&(e=new Event("input",{bubbles:!0}),n.dispatchEvent(e))})();
|
$(function(){var e,t=document.getElementById("dream-search-form"),a=DreamConfig.search_target,n=document.getElementById("halo-search-form-text-input"),i=$("#dream-search-result"),r=$("#dream-search-result-empty");function s(e){return e.replace(/<(?!(?:mark\b[^<>]*)<\/mark>|mark\b)[^<>]*>/gi,"")}function c(e){if(!e)return i.empty(),r.show();Utils.request({url:"/apis/api.halo.run/v1alpha1/indices/post",contentType:"application/json;charset=UTF-8",returnRaw:!0,data:{keyword:e,limit:$("#halo-search-form-limit").val(),highlightPreTag:"<mark>",highlightPostTag:"</mark>"}}).then(e=>{if(console.log(e),0<e.hits.length){r.hide(),i.empty();for(var t=0;t<e.hits.length;t++){var n=e.hits[t];i.append('<div class="widget card search">\n<div class="card-content main">\n<a href="'+n.permalink+'" target="'+a+'">\n<h2 class="title">'+s(n.title)+'</h2>\n</a>\n<div class="main-content not-toc description">\n'+s(n.description)+'\n</div>\n<hr/>\n<div class="meta">\n<div></div>\n<em text="最后更新于 '+Utils.formatDate(n.updateTimestamp,"yyyy年MM月dd日 HH:mm:ss")+'"></em>\n</div>\n</div>\n')}}else r.show(),i.empty()}).catch(e=>{})}t.addEventListener("submit",function(e){e.preventDefault(),c(n.value)}),document.addEventListener("keydown",function(e){"Enter"===e.key&&t.contains(document.activeElement)&&(e.preventDefault(),c(n.value))}),n.addEventListener("input",function(e){c(e.target.value)}),function(e,t=window.location.href){e="keyword".replace(/[\[\]]/g,"\\$&");e=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(t);return e&&e[2]&&decodeURIComponent(e[2].replace(/\+/g," "))}()&&(e=new Event("input",{bubbles:!0}),n.dispatchEvent(e))});
|
@ -30,7 +30,7 @@ spec:
|
|||||||
settingName: theme-dream2-plus-setting
|
settingName: theme-dream2-plus-setting
|
||||||
configMapName: theme-dream2-plus-configMap
|
configMapName: theme-dream2-plus-configMap
|
||||||
# 版本号
|
# 版本号
|
||||||
version: 1.2.7.beta3
|
version: 1.2.7.beta4
|
||||||
# 最低支持的 Halo 版本
|
# 最低支持的 Halo 版本
|
||||||
require: ">=2.15.0"
|
require: ">=2.15.0"
|
||||||
# 许可
|
# 许可
|
||||||
|
Loading…
x
Reference in New Issue
Block a user