This commit is contained in:
j m 2024-04-27 07:31:09 +08:00
parent 3ca60f8da5
commit 33c82ee6ad
3 changed files with 5 additions and 3 deletions

View File

@ -126,7 +126,9 @@ $(document).on('pjax:success', async function (event, data, status, xhr, options
const $currentTarget = $($.parseHTML(data, document, true)) const $currentTarget = $($.parseHTML(data, document, true))
const $head = $('head') const $head = $('head')
$head.find('meta').remove() $head.find('meta').remove()
$head.find('link[rel="canonical"]').remove()
$head.append($currentTarget.filter('meta')) $head.append($currentTarget.filter('meta'))
$head.append($currentTarget.filter('link[rel="canonical"]'))
$currentTarget.filter('link[data-pjax]').each(function () { $currentTarget.filter('link[data-pjax]').each(function () {
let href = $(this).attr('href') let href = $(this).attr('href')
if (!cssLoadCompletes.has(href)) { if (!cssLoadCompletes.has(href)) {
@ -213,6 +215,6 @@ $(document).on('pjax:end', function (event, xhr, options) {
} }
}) })
$(document).on('pjax:popstate', function () { $(document).on('pjax:popstate', function (event) {
console.log('pjax:popstate') console.log('pjax:popstate')
}) })

View File

@ -1 +1 @@
(()=>{const i=new Set($('link[href*=".css"]').map((o,e)=>$(e).attr("href")).get()),l=new Set($('script[src*=".js"]').map((o,e)=>$(e).attr("src")).get()),e=()=>{var o=(new Date).getTime();return window.pjaxSerialNumber=o,console.log("sn = "+o),o},c=(e,n,t)=>{if(n>=e.length)t&&t();else{let o=$(e[n]).attr("src");l.has(o)?c(e,n+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(e,n+1,t)}).fail(function(){console.log((t?"同步":"异步")+"顺序加载js失败 "+o),c(e,n+1,t)}))}};$(document).on("click","a[target!=_blank][href]:not(data-not-pjax)",o=>{$.pjax.click(o,".column-main",{scrollTo:"/"!==o.currentTarget.pathname&&0!==$(".banner").length?(window.initTop=99999999,window.innerHeight/4):0,fragment:".column-main",serialNumber:e(),timeout:8e3})}),$(document).on("submit","form[data-pjax]",function(o){$.pjax.submit(o,".column-main",{scrollTo:0,fragment:".column-main",serialNumber:e(),timeout:8e3})}),$(document).on("pjax:click",function(o,e){console.log("------------------------"),console.log("pjax:click sn = "+e.serialNumber)}),$(document).on("pjax:beforeSend",function(o,e,n){console.log("pjax:beforeSend sn = "+n.serialNumber),$("html").addClass("pjax-loading")}),$(document).on("pjax:start",function(o,e,n){console.log("pjax:start sn = "+n.serialNumber),window.DProgress&&DProgress.start(),$(".pjax-close").remove()}),$(document).on("pjax:send",function(o,e,n){console.log("pjax:send sn = "+n.serialNumber)}),$(document).on("pjax:clicked",function(o,e){console.log("pjax:clicked sn = "+e.serialNumber)}),$(document).on("pjax:beforeReplace",function(o,e,n){console.log("pjax:beforeReplace sn = "+n.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,e,n,t,s){s=s.serialNumber;if(console.log("pjax:success sn = "+s),window.pjaxSerialNumber===s){commonContext.initGallery(),commonContext.initTocAndNotice(),$("html").removeClass("pjax-loading");const a=$($.parseHTML(e,document,!0)),r=$("head");r.find("meta").remove(),r.append(a.filter("meta")),a.filter("link[data-pjax]").each(function(){let o=$(this).attr("href");i.has(o)||(r.append($(this)),console.log("加载css "+$(this).attr("href")),this.onload=function(){i.add(o),window.DProgress&&DProgress.inc(),console.log("加载css完成 "+$(this).attr("href"))})});let o=a.filter("script[data-pjax]");if(0<o.length){o.filter("[async]").each(function(){let o=$(this).attr("src");l.has(o)||(console.log("异步无序加载js "+o),Utils.cachedScript(o).done(function(){console.log("异步无序js完成 "+o),window.DProgress&&DProgress.inc(),l.add(o)}).fail(function(){console.log("异步无序js失败 "+o)}))}),new Promise(()=>{c(o.filter("[defer]"),0)});let e=o.filter(":not([async]):not([defer])");0<e.length&&await new Promise(o=>{c(e,0,o)})}console.log("全部处理完成"),window.pjaxSerialNumber===s&&(window.journalPjax&&window.journalPjax(s),window.postPjax&&window.postPjax(s),commonContext.initTimeCount(),commonContext.initCarousel(),window.DProgress)&&DProgress.done()}}),$(document).on("pjax:timeout",function(o,e,n){console.log("pjax:timeout sn = "+n.serialNumber)}),$(document).on("pjax:error",function(o,e,n,t,s){console.log(`pjax:error sn = ${s.serialNumber} error `+t)}),$(document).on("pjax:complete",function(o,e,n,t){console.log("pjax:complete sn = "+t.serialNumber)}),$(document).on("pjax:end",function(o,e,n){console.log("pjax:end sn = "+n.serialNumber),null==e&&(commonContext.initTocAndNotice(),commonContext.initCarousel(),commonContext.initTimeCount(),window.DProgress&&DProgress.done(),$("html").removeClass("pjax-loading"))}),$(document).on("pjax:popstate",function(){console.log("pjax:popstate")})})(); (()=>{const i=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},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:"/"!==o.currentTarget.pathname&&0!==$(".banner").length?(window.initTop=99999999,window.innerHeight/4):0,fragment:".column-main",serialNumber:n(),timeout:8e3})}),$(document).on("submit","form[data-pjax]",function(o){$.pjax.submit(o,".column-main",{scrollTo:0,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,a){a=a.serialNumber;if(console.log("pjax:success sn = "+a),window.pjaxSerialNumber===a){commonContext.initGallery(),commonContext.initTocAndNotice(),$("html").removeClass("pjax-loading");const s=$($.parseHTML(n,document,!0)),r=$("head");r.find("meta").remove(),r.find('link[rel="canonical"]').remove(),r.append(s.filter("meta")),r.append(s.filter('link[rel="canonical"]')),s.filter("link[data-pjax]").each(function(){let o=$(this).attr("href");i.has(o)||(r.append($(this)),console.log("加载css "+$(this).attr("href")),this.onload=function(){i.add(o),window.DProgress&&DProgress.inc(),console.log("加载css完成 "+$(this).attr("href"))})});let o=s.filter("script[data-pjax]");if(0<o.length){o.filter("[async]").each(function(){let o=$(this).attr("src");l.has(o)||(console.log("异步无序加载js "+o),Utils.cachedScript(o).done(function(){console.log("异步无序js完成 "+o),window.DProgress&&DProgress.inc(),l.add(o)}).fail(function(){console.log("异步无序js失败 "+o)}))}),new Promise(()=>{c(o.filter("[defer]"),0)});let n=o.filter(":not([async]):not([defer])");0<n.length&&await new Promise(o=>{c(n,0,o)})}console.log("全部处理完成"),window.pjaxSerialNumber===a&&(window.journalPjax&&window.journalPjax(a),window.postPjax&&window.postPjax(a),commonContext.initTimeCount(),commonContext.initCarousel(),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,a){console.log(`pjax:error sn = ${a.serialNumber} error `+t)}),$(document).on("pjax:complete",function(o,n,e,t){console.log("pjax:complete sn = "+t.serialNumber)}),$(document).on("pjax:end",function(o,n,e){console.log("pjax:end sn = "+e.serialNumber),null==n&&(commonContext.initTocAndNotice(),commonContext.initCarousel(),commonContext.initTimeCount(),window.DProgress&&DProgress.done(),$("html").removeClass("pjax-loading"))}),$(document).on("pjax:popstate",function(o){console.log("pjax:popstate")})})();

View File

@ -28,6 +28,6 @@ spec:
settingName: theme-dream2-plus-setting settingName: theme-dream2-plus-setting
configMapName: theme-dream2-plus-configMap configMapName: theme-dream2-plus-configMap
# 版本号 # 版本号
version: 1.1.0.0001 version: 1.1.0.2
# 最低支持的 Halo 版本 # 最低支持的 Halo 版本
require: ">=2.12.0" require: ">=2.12.0"