优化,若画廊已打开,则浏览器前进或后退时关闭画廊

This commit is contained in:
j m 2024-12-28 07:52:16 +08:00
parent e2ece7b9f3
commit 1c94695b4c
4 changed files with 12 additions and 2 deletions

View File

@ -362,6 +362,14 @@ const commonContext = {
},
})
},
/** 关闭画廊 **/
closeFancybox() {
// 检测Fancybox是否打开
if (document.querySelector('.fancybox-container')) {
// 关闭Fancybox
$.fancybox.close()
}
},
/* 个人信息界面打印彩字 */
sparkInput() {
const sparkInputContent = DreamConfig.spark_input_content && DreamConfig.spark_input_content.filter(s => s.length > 0)

View File

@ -179,6 +179,8 @@ $(document).on('pjax:success', async function (event, data, status, xhr, options
commonContext.iniTaskItemDisabled()
/* 初始化轮播 */
commonContext.initCarousel()
/** 关闭画廊 **/
commonContext.closeFancybox()
window.DProgress && DProgress.done()
})

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(()=>{const s=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},n=o=>"/"!==o.pathname&&0!==$(".banner").length?(window.initTop=99999999,window.innerHeight/4):0,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:n(o.currentTarget),fragment:".column-main",serialNumber:e(),timeout:8e3})}),$(document).on("submit","form[data-pjax]",function(o){$.pjax.submit(o,".column-main",{scrollTo:n(o.currentTarget),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,a){a=a.serialNumber;if(console.log("pjax:success sn = "+a),window.pjaxSerialNumber===a){commonContext.initGallery(),commonContext.initTocAndNotice(),$("html").removeClass("pjax-loading");const i=$($.parseHTML(e,document,!0)),r=$("head");r.find("meta").remove(),r.find('link[rel="canonical"]').remove(),r.append(i.filter("meta")),r.append(i.filter('link[rel="canonical"]')),i.filter("link[data-pjax]").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=i.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===a&&(window.journalPjax&&window.journalPjax(a),window.postPjax&&window.postPjax(a),commonContext.initTimeCount(),commonContext.iniTaskItemDisabled(),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,a){console.log(`pjax:error sn = ${a.serialNumber} error `+t)}),$(document).on("pjax:complete",function(o,e,n,t){console.log("pjax:complete sn = "+t.serialNumber);var t=document.title,a=window.location.pathname,i=window.location.href;window.history&&window.history.replaceState&&window.history.replaceState({url:i,title:t,path:a},t,i)}),$(document).on("pjax:end",function(o,e,n){console.log("pjax:end sn = "+n.serialNumber),null==e&&(commonContext.initTocAndNotice(),commonContext.initCarousel(),commonContext.initTimeCount(),commonContext.iniTaskItemDisabled(),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"),o.state){const o=window.location.href;$.pjax.reload(".column-main",{container:".column-main",push:!1,url:o,fragment:".column-main",serialNumber:e(),timeout:8e3})}})})();
(()=>{const s=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},n=o=>"/"!==o.pathname&&0!==$(".banner").length?(window.initTop=99999999,window.innerHeight/4):0,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:n(o.currentTarget),fragment:".column-main",serialNumber:e(),timeout:8e3})}),$(document).on("submit","form[data-pjax]",function(o){$.pjax.submit(o,".column-main",{scrollTo:n(o.currentTarget),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,a){a=a.serialNumber;if(console.log("pjax:success sn = "+a),window.pjaxSerialNumber===a){commonContext.initGallery(),commonContext.initTocAndNotice(),$("html").removeClass("pjax-loading");const i=$($.parseHTML(e,document,!0)),r=$("head");r.find("meta").remove(),r.find('link[rel="canonical"]').remove(),r.append(i.filter("meta")),r.append(i.filter('link[rel="canonical"]')),i.filter("link[data-pjax]").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=i.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===a&&(window.journalPjax&&window.journalPjax(a),window.postPjax&&window.postPjax(a),commonContext.initTimeCount(),commonContext.iniTaskItemDisabled(),commonContext.initCarousel(),commonContext.closeFancybox(),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,a){console.log(`pjax:error sn = ${a.serialNumber} error `+t)}),$(document).on("pjax:complete",function(o,e,n,t){console.log("pjax:complete sn = "+t.serialNumber);var t=document.title,a=window.location.pathname,i=window.location.href;window.history&&window.history.replaceState&&window.history.replaceState({url:i,title:t,path:a},t,i)}),$(document).on("pjax:end",function(o,e,n){console.log("pjax:end sn = "+n.serialNumber),null==e&&(commonContext.initTocAndNotice(),commonContext.initCarousel(),commonContext.initTimeCount(),commonContext.iniTaskItemDisabled(),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"),o.state){const o=window.location.href;$.pjax.reload(".column-main",{container:".column-main",push:!1,url:o,fragment:".column-main",serialNumber:e(),timeout:8e3})}})})();