From 4b8a610c086dc199cb42ff674364a77f960e492a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B0=E6=A2=A6?= <68908911+icemyst@users.noreply.github.com> Date: Thu, 20 Feb 2025 14:10:13 +0800 Subject: [PATCH] Update pjax.pug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 自定义404.html跳转更平滑,使用 window.location.href = e.request.responseURL 加载,自定义404.html加载速度缓慢,可能会出现loading二次加载 --- layout/includes/third-party/pjax.pug | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/layout/includes/third-party/pjax.pug b/layout/includes/third-party/pjax.pug index a8094f1..94ec038 100644 --- a/layout/includes/third-party/pjax.pug +++ b/layout/includes/third-party/pjax.pug @@ -59,7 +59,10 @@ script. document.addEventListener('pjax:error', e => { if (e.request.status === 404) { - window.location.href = e.request.responseURL + const usePjax = !{theme.pjax && theme.pjax.enable} + !{theme.error_404 && theme.error_404.enable} + ? (usePjax ? pjax.loadUrl('!{url_for("/404.html")}') : window.location.href = '!{url_for("/404.html")}') + : window.location.href = e.request.responseURL } }) - })() \ No newline at end of file + })()