From 55628bb0601da849d7d121a768861c53c37a8255 Mon Sep 17 00:00:00 2001 From: mjsoftware <1406993111@qq.com> Date: Sun, 26 Jan 2025 14:57:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96katex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/pjax.js | 4 ++-- templates/assets/js/pjax.min.js | 2 +- templates/common/head.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/pjax.js b/src/js/pjax.js index e0fae66..a1edcd7 100644 --- a/src/js/pjax.js +++ b/src/js/pjax.js @@ -132,7 +132,7 @@ $(document).on('pjax:success', async function (event, data, status, xhr, options $currentTarget.filter('link').filter(function() { const isDataPjax = $(this).is('[data-pjax]') const href = $(this).attr('href') - const isStaticPath = href && (href.startsWith('/plugins/PluginHighlightJS/')) + const isStaticPath = href && (href.startsWith('/plugins/PluginHighlightJS/') || href.startsWith('/plugins/plugin-katex/')) return isDataPjax || isStaticPath }).each(function () { let href = $(this).attr('href') @@ -149,7 +149,7 @@ $(document).on('pjax:success', async function (event, data, status, xhr, options let $scripts = $currentTarget.filter('script').filter(function() { const isDataPjax = $(this).is('[data-pjax]') const src = $(this).attr('src') - const isStaticPath = src && (src.startsWith('/plugins/PluginHighlightJS/')) + const isStaticPath = src && (src.startsWith('/plugins/PluginHighlightJS/') || src.startsWith('/plugins/plugin-katex/')) return isDataPjax || isStaticPath }) if ($scripts.length > 0) { diff --git a/templates/assets/js/pjax.min.js b/templates/assets/js/pjax.min.js index 86d9d49..6e82477 100644 --- a/templates/assets/js/pjax.min.js +++ b/templates/assets/js/pjax.min.js @@ -1 +1 @@ -(()=>{const s=new Set($('link[href*=".css"]').map((o,n)=>$(n).attr("href")).get()),l=new Set($('script[src*=".js"]').map((o,n)=>$(n).attr("src")).get()),n=()=>{var o=(new Date).getTime();return window.pjaxSerialNumber=o,console.log("sn = "+o),o},e=o=>"/"!==o.pathname&&0!==$(".banner").length?(window.initTop=99999999,window.innerHeight/4):0,c=(n,e,t)=>{if(e>=n.length)t&&t();else{let o=$(n[e]).attr("src");l.has(o)?c(n,e+1,t):(console.log((t?"同步":"异步")+"顺序加载js "+o),Utils.cachedScript(o).done(function(){console.log((t?"同步":"异步")+"顺序加载js完成 "+o),l.add(o),window.DProgress&&DProgress.inc(),c(n,e+1,t)}).fail(function(){console.log((t?"同步":"异步")+"顺序加载js失败 "+o),c(n,e+1,t)}))}};$(document).on("click","a[target!=_blank][href]:not([data-not-pjax])",o=>{$.pjax.click(o,".column-main",{scrollTo:e(o.currentTarget),fragment:".column-main",serialNumber:n(),timeout:8e3})}),$(document).on("submit","form[data-pjax]",function(o){$.pjax.submit(o,".column-main",{scrollTo:e(o.currentTarget),fragment:".column-main",serialNumber:n(),timeout:8e3})}),$(document).on("pjax:click",function(o,n){console.log("------------------------"),console.log("pjax:click sn = "+n.serialNumber)}),$(document).on("pjax:beforeSend",function(o,n,e){console.log("pjax:beforeSend sn = "+e.serialNumber),$("html").addClass("pjax-loading")}),$(document).on("pjax:start",function(o,n,e){console.log("pjax:start sn = "+e.serialNumber),window.DProgress&&DProgress.start(),$(".pjax-close").remove()}),$(document).on("pjax:send",function(o,n,e){console.log("pjax:send sn = "+e.serialNumber)}),$(document).on("pjax:clicked",function(o,n){console.log("pjax:clicked sn = "+n.serialNumber)}),$(document).on("pjax:beforeReplace",function(o,n,e){console.log("pjax:beforeReplace sn = "+e.serialNumber),$(".navbar-nav .current,.panel-side-menu .current").removeClass("current"),commonContext.initNavbar(),0<$("html.disable-scroll").length&&$(".navbar-mask").trigger("click")}),$(document).on("pjax:success",async function(o,n,e,t,i){i=i.serialNumber;if(console.log("pjax:success sn = "+i),window.pjaxSerialNumber===i){commonContext.initGallery(),commonContext.initTocAndNotice(),$("html").removeClass("pjax-loading");const a=$($.parseHTML(n,document,!0)),r=$("head");r.find("meta").remove(),r.find('link[rel="canonical"]').remove(),r.append(a.filter("meta")),r.append(a.filter('link[rel="canonical"]')),a.filter("link").filter(function(){var o=$(this).is("[data-pjax]"),n=$(this).attr("href"),n=n&&n.startsWith("/plugins/PluginHighlightJS/");return o||n}).each(function(){let o=$(this).attr("href");s.has(o)||(r.append($(this)),console.log("加载css "+$(this).attr("href")),this.onload=function(){s.add(o),window.DProgress&&DProgress.inc(),console.log("加载css完成 "+$(this).attr("href"))})});let o=a.filter("script").filter(function(){var o=$(this).is("[data-pjax]"),n=$(this).attr("src"),n=n&&n.startsWith("/plugins/PluginHighlightJS/");return o||n});if(0{c(o.filter("[defer]"),0)});let n=o.filter(":not([async]):not([defer])");0{c(n,0,o)})}console.log("全部处理完成"),window.pjaxSerialNumber===i&&(window.journalPjax&&window.journalPjax(i),window.postPjax&&window.postPjax(i),window.initKatex&&window.initKatex(),commonContext.initTimeCount(),commonContext.iniTaskItemDisabled(),commonContext.initCarousel(),commonContext.closeFancybox(),window.DProgress)&&DProgress.done()}}),$(document).on("pjax:timeout",function(o,n,e){console.log("pjax:timeout sn = "+e.serialNumber)}),$(document).on("pjax:error",function(o,n,e,t,i){console.log(`pjax:error sn = ${i.serialNumber} error `+t)}),$(document).on("pjax:complete",function(o,n,e,t){if(console.log("pjax:complete sn = "+t.serialNumber),DreamConfig.site_comment){const o=document.title,n=window.location.pathname,e=window.location.href;window.history&&window.history.replaceState&&window.history.replaceState({url:e,title:o,path:n},o,e)}}),$(document).on("pjax:end",function(o,n,e){console.log("pjax:end sn = "+e.serialNumber),null==n&&(commonContext.initTocAndNotice(),commonContext.initCarousel(),commonContext.initTimeCount(),commonContext.iniTaskItemDisabled(),commonContext.closeFancybox(),window.DProgress&&DProgress.done(),$("html").removeClass("pjax-loading"))}),$(document).on("pjax:popstate",function(o){console.log("pjax:popstate")}),window.addEventListener("popstate",function(o){if(console.log("popstate event triggered"),DreamConfig.site_comment&&o.state){const o=window.location.href;$.pjax.reload(".column-main",{container:".column-main",push:!1,url:o,fragment:".column-main",serialNumber:n(),timeout:8e3})}})})(); \ No newline at end of file +(()=>{const r=new Set($('link[href*=".css"]').map((n,o)=>$(o).attr("href")).get()),l=new Set($('script[src*=".js"]').map((n,o)=>$(o).attr("src")).get()),o=()=>{var n=(new Date).getTime();return window.pjaxSerialNumber=n,console.log("sn = "+n),n},e=n=>"/"!==n.pathname&&0!==$(".banner").length?(window.initTop=99999999,window.innerHeight/4):0,c=(o,e,t)=>{if(e>=o.length)t&&t();else{let n=$(o[e]).attr("src");l.has(n)?c(o,e+1,t):(console.log((t?"同步":"异步")+"顺序加载js "+n),Utils.cachedScript(n).done(function(){console.log((t?"同步":"异步")+"顺序加载js完成 "+n),l.add(n),window.DProgress&&DProgress.inc(),c(o,e+1,t)}).fail(function(){console.log((t?"同步":"异步")+"顺序加载js失败 "+n),c(o,e+1,t)}))}};$(document).on("click","a[target!=_blank][href]:not([data-not-pjax])",n=>{$.pjax.click(n,".column-main",{scrollTo:e(n.currentTarget),fragment:".column-main",serialNumber:o(),timeout:8e3})}),$(document).on("submit","form[data-pjax]",function(n){$.pjax.submit(n,".column-main",{scrollTo:e(n.currentTarget),fragment:".column-main",serialNumber:o(),timeout:8e3})}),$(document).on("pjax:click",function(n,o){console.log("------------------------"),console.log("pjax:click sn = "+o.serialNumber)}),$(document).on("pjax:beforeSend",function(n,o,e){console.log("pjax:beforeSend sn = "+e.serialNumber),$("html").addClass("pjax-loading")}),$(document).on("pjax:start",function(n,o,e){console.log("pjax:start sn = "+e.serialNumber),window.DProgress&&DProgress.start(),$(".pjax-close").remove()}),$(document).on("pjax:send",function(n,o,e){console.log("pjax:send sn = "+e.serialNumber)}),$(document).on("pjax:clicked",function(n,o){console.log("pjax:clicked sn = "+o.serialNumber)}),$(document).on("pjax:beforeReplace",function(n,o,e){console.log("pjax:beforeReplace sn = "+e.serialNumber),$(".navbar-nav .current,.panel-side-menu .current").removeClass("current"),commonContext.initNavbar(),0<$("html.disable-scroll").length&&$(".navbar-mask").trigger("click")}),$(document).on("pjax:success",async function(n,o,e,t,i){i=i.serialNumber;if(console.log("pjax:success sn = "+i),window.pjaxSerialNumber===i){commonContext.initGallery(),commonContext.initTocAndNotice(),$("html").removeClass("pjax-loading");const a=$($.parseHTML(o,document,!0)),s=$("head");s.find("meta").remove(),s.find('link[rel="canonical"]').remove(),s.append(a.filter("meta")),s.append(a.filter('link[rel="canonical"]')),a.filter("link").filter(function(){var n=$(this).is("[data-pjax]"),o=$(this).attr("href"),o=o&&(o.startsWith("/plugins/PluginHighlightJS/")||o.startsWith("/plugins/plugin-katex/"));return n||o}).each(function(){let n=$(this).attr("href");r.has(n)||(s.append($(this)),console.log("加载css "+$(this).attr("href")),this.onload=function(){r.add(n),window.DProgress&&DProgress.inc(),console.log("加载css完成 "+$(this).attr("href"))})});let n=a.filter("script").filter(function(){var n=$(this).is("[data-pjax]"),o=$(this).attr("src"),o=o&&(o.startsWith("/plugins/PluginHighlightJS/")||o.startsWith("/plugins/plugin-katex/"));return n||o});if(0{c(n.filter("[defer]"),0)});let o=n.filter(":not([async]):not([defer])");0{c(o,0,n)})}console.log("全部处理完成"),window.pjaxSerialNumber===i&&(window.journalPjax&&window.journalPjax(i),window.postPjax&&window.postPjax(i),window.initKatex&&window.initKatex(),commonContext.initTimeCount(),commonContext.iniTaskItemDisabled(),commonContext.initCarousel(),commonContext.closeFancybox(),window.DProgress)&&DProgress.done()}}),$(document).on("pjax:timeout",function(n,o,e){console.log("pjax:timeout sn = "+e.serialNumber)}),$(document).on("pjax:error",function(n,o,e,t,i){console.log(`pjax:error sn = ${i.serialNumber} error `+t)}),$(document).on("pjax:complete",function(n,o,e,t){if(console.log("pjax:complete sn = "+t.serialNumber),DreamConfig.site_comment){const n=document.title,o=window.location.pathname,e=window.location.href;window.history&&window.history.replaceState&&window.history.replaceState({url:e,title:n,path:o},n,e)}}),$(document).on("pjax:end",function(n,o,e){console.log("pjax:end sn = "+e.serialNumber),null==o&&(commonContext.initTocAndNotice(),commonContext.initCarousel(),commonContext.initTimeCount(),commonContext.iniTaskItemDisabled(),commonContext.closeFancybox(),window.DProgress&&DProgress.done(),$("html").removeClass("pjax-loading"))}),$(document).on("pjax:popstate",function(n){console.log("pjax:popstate")}),window.addEventListener("popstate",function(n){if(console.log("popstate event triggered"),DreamConfig.site_comment&&n.state){const n=window.location.href;$.pjax.reload(".column-main",{container:".column-main",push:!1,url:n,fragment:".column-main",serialNumber:o(),timeout:8e3})}})})(); \ No newline at end of file diff --git a/templates/common/head.html b/templates/common/head.html index 826e626..173b170 100644 --- a/templates/common/head.html +++ b/templates/common/head.html @@ -2,7 +2,7 @@ th:with="description=${isPost ? post != null ? post.status.excerpt : singlePage != null ? singlePage.status.excerpt : site.seo.description : site.seo.description}"> - +