diff --git a/src/js/pjax.js b/src/js/pjax.js index a1edcd7..d96e87b 100644 --- a/src/js/pjax.js +++ b/src/js/pjax.js @@ -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/') || src.startsWith('/plugins/plugin-katex/')) + const isStaticPath = src && (src.startsWith('/plugins/PluginHighlightJS/')) return isDataPjax || isStaticPath }) if ($scripts.length > 0) { diff --git a/templates/assets/js/pjax.min.js b/templates/assets/js/pjax.min.js index 6e82477..76896d4 100644 --- a/templates/assets/js/pjax.min.js +++ b/templates/assets/js/pjax.min.js @@ -1 +1 @@ -(()=>{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 +(()=>{const s=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)),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 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");s.has(n)||(r.append($(this)),console.log("加载css "+$(this).attr("href")),this.onload=function(){s.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/");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/scripts.html b/templates/common/scripts.html index 7762abc..4d08fae 100644 --- a/templates/common/scripts.html +++ b/templates/common/scripts.html @@ -10,6 +10,7 @@ + diff --git a/theme.yaml b/theme.yaml index ddb9c35..241df07 100644 --- a/theme.yaml +++ b/theme.yaml @@ -30,7 +30,7 @@ spec: settingName: theme-dream2-plus-setting configMapName: theme-dream2-plus-configMap # 版本号 - version: 1.3.8.beta4 + version: 1.3.8.beta5 # 最低支持的 Halo 版本 require: ">=2.20.0" # 许可