$(document).ready(function(){function e(e=d.LIGHT){let o=e;e===d.SYSTEM&&(o=t()),$("html").attr("data-theme",o),n("theme",e,7),n("system_theme",o,1)}function t(){return window.matchMedia("(prefers-color-scheme: dark)").matches?d.DARK:d.LIGHT}function n(e,t,n){const o=new Date;o.setTime(o.getTime()+24*n*60*60*1e3),document.cookie=`${e}=${t}; expires=${o.toUTCString()}; path=/`}function o(e){$(".theme-toggle button").removeClass("active"),e.addClass("active")}function s(){const e=i("theme")||d.LIGHT;let t;t=e===d.LIGHT?$('.theme-toggle button[title="浅色模式"]'):e===d.DARK?$('.theme-toggle button[title="深色模式"]'):e===d.SYSTEM?$('.theme-toggle button[title="跟随系统"]'):$('.theme-toggle button[title="浅色模式"]'),o(t)}function i(e){const t=document.cookie.split(";");for(let n of t){const[t,o]=n.trim().split("=");if(t===e)return o}return null}function a(e,t,n){const o="wechat-qrcode"===t?"zdyqr-qrcode":"wechat-qrcode";$(document).on("click",e,function(){const e=$(`.${t}`),s=$(`.${o}`),i=$(".share-box");if(e.length)e.remove();else{s.remove();const e=decodeURIComponent(_ARTICLE_URL),o=`\n
\n 分享二维码\n
${n}
\n
\n `;i.append(o)}})}function c(e,t){return function(){$(this).addClass(e).removeClass(t)}}function r(e,t){$(e).each(function(e){var n=e*t+"s";$(this).css("animation-delay",n)})}const l=(e,t)=>{let n=null;return function(){n||(n=setTimeout(()=>{e.apply(this,arguments),n=null},t))}};$("#nav-backtop").click(function(){return $("html, body").animate({scrollTop:0},200),!1});const d={LIGHT:"light",DARK:"dark",SYSTEM:"system"};$(".theme-toggle").on("click","button",function(){const t=$(this).attr("title");switch(t){case"浅色模式":e(d.LIGHT);break;case"深色模式":e(d.DARK);break;case"跟随系统":e(d.SYSTEM)}o($(this))}),s(),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{e(d.SYSTEM)});const m=()=>{const e=$(window).scrollTop(),t=$(document).height(),n=$(window).height(),o=Math.round(e/(t-n)*100);o>0?($("#nav-backtop").toggleClass("top-to-active",o>=90),$(".back-to-top").show(),$("#nav-backtop>.top-to-text").text(o>=90?"回到顶部":o)):$(".back-to-top").hide()};let p=!1;$("#navbar").hasClass("nav-ui-one")&&(p=!0),toggleNavOnScroll=((e,t,n,o=100)=>{if(p)return;const s=$(e),i=$(this).scrollTop();i>o?s.hasClass(n)&&s.removeClass(n).addClass(t):s.hasClass(t)&&s.removeClass(t).addClass(n)}),m(),toggleNavOnScroll("#navbar","nav-ui-one","nav-ui-two",100),$(window).scroll(function(){l(m(),100),l(toggleNavOnScroll("#navbar","nav-ui-one","nav-ui-two",50),100)});let u=0,v=0,h=!1;$("#menu-line").click(function(e){e.stopPropagation();const t=$("#nav-components");if(t.length)return void f();const n=$("#mobile-nav");n.append('
');const o=$(".nav-inner > ul").clone();o.find(".sub-menu").addClass("mt-1"),o.find(".sub-menu>ul").addClass("row p-1 ml-2"),o.find(".sub-menu>ul>li").addClass("col-4 p-1"),o.find(".nav-item").addClass("pb-3"),o.find(".nav-item>.nav-a").addClass("font-weight-bold"),o.find(".nav-item>.nav-a").prepend(''),n.append(``),requestAnimationFrame(()=>{$("#mobile-nav-bg").css({opacity:"1",visibility:"visible",transform:"rotate(0) scale(1)"}),$("#nav-components").addClass("open")}),$("body").css("overflow","hidden")}),$(document).click(function(e){!$("#nav-components").hasClass("open")||$(e.target).closest("#nav-components").length||$(e.target).closest("#menu-line").length||f()}),$("#nav-components").click(function(e){e.stopPropagation()}),$(document).on("touchstart",function(e){$("#nav-components").hasClass("open")&&(u=e.originalEvent.touches[0].pageY,v=u,h=!0)}),$(document).on("touchmove",function(e){if(h){v=e.originalEvent.touches[0].pageY;const t=v-u;t>0&&$("#nav-components").css("transform",`translateY(${t}px)`)}}),$(document).on("touchend",function(){if(h){const e=v-u,t=$("#nav-components").height()/2;e>t?f():$("#nav-components").css("transform",""),h=!1}}),$(document).on("click","#mobile-close-btn",function(){f()});const f=()=>{const e=$("#nav-components"),t=$("#mobile-nav-bg");e.removeClass("open"),t.css({opacity:0,visibility:"hidden"}),e.one("transitionend",function(){e.remove(),t.remove(),$("body").css("overflow","")})};$("#search-btn").click(function(){$(".main-search").addClass("open"),$("body").css("overflow","hidden")}),$(".search-box").on("click","#search-close-btn",function(){$(".main-search").removeClass("open"),$("body").css("overflow","")});const b=(e,t=200)=>{const n=document.createElement("div");$(n).qrcode({text:e,width:t,height:t});const o=n.querySelector("canvas");if(!o)return console.error("二维码生成失败:未创建canvas元素"),null;try{return o.toDataURL("image/png")}catch(e){return console.error("Base64转换失败:",e),null}},g=(e,t,n)=>$('
'+t+("poster"==e?"":'
')+"
"),w=(e,t)=>{0===$(e).length&&$("body").append(t()),requestAnimationFrame(()=>{$(e).addClass("open"),$("body").css("overflow","hidden")})},y=e=>{e.removeClass("open"),$("body").css("overflow",""),setTimeout(function(){e.remove()},500)};$(document).on("click",".close-btn,.pop-close-btn",function(){const e=$(this).closest(".main-poster, .main-reward, .main-share");y(e)}),$(document).click(function(e){const t=$(e.target);!t.closest(".search-box, #search-btn").length&&$(".search-box").is(":visible")&&($(".main-search").removeClass("open"),$("body").css("overflow","")),!t.closest(".poster-box, #poster-btn, .down-btn-box").length&&$(".poster-box").is(":visible")&&y($(".main-poster")),!t.closest(".reward-box, #reward-btn").length&&$(".reward-box").is(":visible")&&y($(".main-reward")),!t.closest(".share-box, #share-btn").length&&$(".share-box").is(":visible")&&y($(".main-share"))}),$(document).click(function(e){e.stopPropagation()});const C=()=>{var e=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"],t=new Date,n=t.getDate();const o=n<10?"0"+n:n,s=t.getDay(),i=$("#logo>img").attr("src"),a=$(".author-left>name>a").first().text(),c=$(".post-category > a").first().text();return g("poster",`
\n
\n
\n
\n
${e[s]}
\n
${o}
\n
\n
\n
${decodeURIComponent(_ARTICLE_NAME)}
\n

作者:${a} | 分类:${c}

\n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n `,"poster-close-btn")};$("#poster-btn").click(function(){w(".main-poster",C)}),$(document).on("click","#poster-download-btn",function(){htmlToImage.toPng(document.querySelector("#posterCapture")).then(function(e){var t=document.createElement("a");t.download=decodeURIComponent(_ARTICLE_NAME)+"-海报图片.png",t.href=e,t.click()})});const x=()=>g("reward",'
微信
支付宝
',"reward-close-btn");$("#reward-btn").click(function(){w(".main-reward",x)});const R={qq:"http://connect.qq.com/widget/shareqq/index.html?url=",weibo:"http://service.weibo.com/share/share.php?url=",twitter:"https://twitter.com/intent/tweet?url=",wechat:"javascript:void(0);"},I=()=>g("share",'

'+decodeURIComponent(_ARTICLE_URL)+'

',"share-close-btn");$("#share-btn").click(function(){w(".main-share",I)}),a("#share-wechat","wechat-qrcode","微信扫码分享"),a("#share-zdyqr","zdyqr-qrcode","扫码分享");const k=e=>{const t=$.extend({duration:1500,easing:e=>e*(2-e),format:e=>e.toLocaleString()},e),n=$(t.selector);if(!n.length)return void console.error("元素未找到:",t.selector);let o=null;const s=t.end-t.start,i=Math.abs(s)>1e4,a=e=>{o=o||e;const c=e-o,r=Math.min(c/t.duration,1),l=t.easing(r);let d=t.start+s*l;if(i){const e=t.end-d;d=Math.abs(e)>1e3?t.end-e*(1+Math.random()/3):d}n.text(t.format(Math.floor(d))),r<1?requestAnimationFrame(a):n.text(t.format(t.end))};requestAnimationFrame(a)};var T={effect:"fadeIn",threshold:200,container:window,failure_limit:30};$("img.lazy").lazyload($.extend({},T,{load:c("loaded","lazy")})),$(".hh-widget img.widget-lazy").lazyload($.extend({},T,{load:c("loaded","widget-lazy")}));let L=0;const A=$("#navbar"),_=$(".sidebar-sticky"),q=100;if($(window).scroll(function(){const e=$(this).scrollTop();if(e5&&(e>L?(A.removeClass("nav-visible").addClass("nav-hidden"),_.addClass("visible-top")):(A.removeClass("nav-hidden").addClass("nav-visible"),_.removeClass("visible-top"))),L=e}),r(".nav-menu>.nav-item",.15),r(".hh-widget:not(.no-animation)",.3),r(".card:not(.no-animation)",.3),r(".links-card",.3),"undefined"!=typeof Swiper){var E=new Swiper(".swiper-container",{direction:"horizontal",loop:!0,autoplay:5e3,speed:1e3,autoplayDisableOnInteraction:!1,pagination:".swiper-pagination",paginationClickable:!0,prevButton:".swiper-button-prev",nextButton:".swiper-button-next",roundLengths:!0,parallax:!0,lazyLoading:!0});$(".swiper-container").mouseenter(function(){E.stopAutoplay()}).mouseleave(function(){E.startAutoplay()}),$(".swiper-container").hover(function(){E.stopAutoplay()},function(){E.startAutoplay()})}if("undefined"!=typeof ViewImage&&window.ViewImage&&ViewImage.init(".post-content img[show-img],.comment-list img"),showSvg(),$(".timejourney-progress").length>0){var U=$(".timejourney-progress").data("percentage");const e=U||0;$(".timejourney-progress").css({width:e+"%",transition:"width "+(e/10+1)+"s ease-in-out"}),k({start:0,end:e,duration:e/10*1e3+1500,selector:"#timejourney-progress",format:e=>`${e}%`})}});