From 6f9149cc08ab998655bbefacdb6dfd6f682d1e87 Mon Sep 17 00:00:00 2001 From: MHuiG <616001163@qq.com> Date: Thu, 24 Nov 2022 15:01:08 +0800 Subject: [PATCH] =?UTF-8?q?perf(search/hexo):=20=E6=8F=90=E5=89=8D?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=90=9C=E7=B4=A2=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layout/_plugins/pace/script.ejs | 1 + source/js/search/hexo.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/layout/_plugins/pace/script.ejs b/layout/_plugins/pace/script.ejs index e77af6fde..46a836a1f 100644 --- a/layout/_plugins/pace/script.ejs +++ b/layout/_plugins/pace/script.ejs @@ -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:配置项开关, 哪些页面添加阅读进度 }) diff --git a/source/js/search/hexo.js b/source/js/search/hexo.js index b8f6d1d9c..e0052b264 100644 --- a/source/js/search/hexo.js +++ b/source/js/search/hexo.js @@ -20,7 +20,7 @@ let SearchService = (() => {
`; - fn.init = () => { + fn.init = async () => { let div = document.createElement("div"); div.innerHTML += fn.template; document.body.append(div); @@ -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();