Skip to content

Commit

Permalink
perf(search/hexo): 提前加载搜索数据
Browse files Browse the repository at this point in the history
  • Loading branch information
MHuiG committed Nov 24, 2022
1 parent 6626fc0 commit 6f9149c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions layout/_plugins/pace/script.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Pace.stop();
Pace.trigger('start');
Pace.bar.update(volantis.scroll.progress() * 100);
document.body.className = document.body.className.replaceAll("pace-running ","");
},"阅读进度")
// todo:配置项开关, 哪些页面添加阅读进度
})
Expand Down
5 changes: 4 additions & 1 deletion source/js/search/hexo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let SearchService = (() => {
<div id="modal-overlay" class="modal-overlay"></div>
</div>
`;
fn.init = () => {
fn.init = async () => {
let div = document.createElement("div");
div.innerHTML += fn.template;
document.body.append(div);
Expand All @@ -35,6 +35,9 @@ let SearchService = (() => {
document
.querySelector("#modal-overlay")
.addEventListener("click", fn.close, false);
if (!fn.data) {
fn.data = await fn.fetchData();
}
};
fn.onSubmit = (event) => {
event.preventDefault();
Expand Down

0 comments on commit 6f9149c

Please sign in to comment.