From 7344bff617efa2f219c4955bcacd98f4c075ba7c Mon Sep 17 00:00:00 2001 From: j m <1406993111@qq.com> Date: Fri, 27 Dec 2024 08:00:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=89=93=E5=BC=80=E7=94=BB?= =?UTF-8?q?=E5=BB=8A=E4=B8=8D=E6=94=B9=E5=8F=98URL=E9=81=BF=E5=85=8Dpjax?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E9=87=8D=E6=96=B0=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/common.js | 2 +- src/js/mew-custom.js | 2 +- templates/assets/js/common.min.js | 4 ++-- templates/assets/js/mew-custom.min.js | 2 +- templates/photos.html | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/js/common.js b/src/js/common.js index 5a99bc9..b212c21 100644 --- a/src/js/common.js +++ b/src/js/common.js @@ -61,7 +61,7 @@ const commonContext = { // 用链接和标题包装图像 $('.main-content img:not(.not-gallery)').each(function () { if ($(this).parents('[data-fancybox],mew-photos').length === 0) { - $(this).wrap(``)})},initMode(){let t=localStorage.getItem("night")||!1;const n=e=>{e?$("html").addClass("color-scheme-dark").removeClass("color-scheme-light").addClass("night"):$("html").addClass("color-scheme-light").removeClass("color-scheme-dark").removeClass("night"),localStorage.setItem("night",e),t=e};$("#toggle-mode").on("click",()=>n("true"!==t.toString())),"system"===DreamConfig.default_theme?window.matchMedia("(prefers-color-scheme: dark)").addListener(e=>n(e.matches)):n("true"===t.toString())},initNavbar(){var t=$(".navbar-nav a"),e=$(".panel-side-menu .link");let n=0;var{href:i,pathname:a}=location;if(a&&"/"!==a)for(let e=0;e$(this).addClass("active"),()=>$(this).removeClass("active")):($(this).on("click",function(e){e.stopPropagation(),$(this).toggleClass("active"),$(document).one("click",()=>$(this).removeClass("active")),e.stopPropagation()}),n.on("click",e=>e.stopPropagation()))})},iniTaskItemDisabled(){$('li[data-type="taskItem"]').each(function(){$(this).find('label > input[type="checkbox"]').prop("disabled",!0)})},initLogonMenu(){$(".navbar-logon").each(function(e,t){"hover"===($(t).attr("trigger")||"click")?$(this).hover(()=>$(this).addClass("active"),()=>$(this).removeClass("active")):$(this).on("click",function(e){e.stopPropagation(),$(this).toggleClass("active"),$(document).one("click",()=>$(this).removeClass("active")),e.stopPropagation()})})},initScroll(){window.initTop=0,document.addEventListener("scroll",()=>{const e=$(document).scrollTop(),t=(a=e>window.initTop,window.initTop=e,a),n=$("body"),i=$(".actions");var a;50e.preventDefault),$(".navbar .toc-content").on("click",function(e){e.stopPropagation(),$("html").removeClass("disable-scroll"),$(".navbar-mask").removeClass("active slideout"),$(".navbar-slideout").removeClass("active slideout-toc")})},sideMenuMobile(){$(".navbar-slideout-menu .current").parents(".panel-body").show().siblings(".panel").addClass("in"),$(".navbar-slideout-menu .panel").on("click",function(e){e.stopPropagation();var e=$(this),t=e.parent().parent();t.find(".panel").not(e).removeClass("in"),t.find(".panel-body").not(e.siblings(".panel-body")).stop().hide("fast"),e.toggleClass("in").siblings(".panel-body").stop().toggle("fast")})},initEvent(){var e=$("body");function n(e){var e=$(e),t=e.attr("data-close");return t&&""!==t.trim()?e.closest(t.trim()):e}e.on("click",".click-close",function(e){e.stopPropagation(),n(this).remove()}),e.on("click",".click-animation-close",function(e){e.stopPropagation();let t=n(this);t.addClass("close-animation"),setTimeout(()=>t.remove(),300)})},offscreenTip(){if(!Utils.isMobile()&&(DreamConfig.document_hidden_title||DreamConfig.document_visible_title)){let e=document.title,t=null;document.addEventListener("visibilitychange",function(){document.hidden?(DreamConfig.document_visible_title&&document.title===DreamConfig.document_visible_title||(e=document.title),DreamConfig.document_hidden_title&&(document.title=DreamConfig.document_hidden_title),clearTimeout(t)):(document.title=DreamConfig.document_visible_title||e,DreamConfig.document_visible_title&&(t=setTimeout(function(){document.title===DreamConfig.document_visible_title&&(document.title=e)},2e3)))})}},initCarousel(){window.Swiper&&new Swiper(".swiper",{loop:!0,parallax:!0,effect:"slide",spaceBetween:10,speed:600,autoplay:{delay:3e3,disableOnInteraction:!1,pauseOnMouseEnter:!0},pagination:{el:".swiper-pagination",clickable:!0},navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"}})},sparkInput(){const n=DreamConfig.spark_input_content&&DreamConfig.spark_input_content.filter(e=>0sparkInput(t,[t.innerText,...n]))})},loveTime(){let c=$(".love .love-time");if(0!==c.length){var e=c.attr("data-time");if(/^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}$/.test(e)){const d=new Date(e);setInterval(function(){var e=Date.now(),t=parseInt((e-d)/1e3),n=t%60,i=(t=parseInt(t/60))%60;let a=(t=parseInt(t/60))%24,o=parseInt(t/24),s=0,r=d.getFullYear(),l=e.getFullYear();for(;r${o}天${a}${i}${n}秒`},300)}}},webCopyright(){var e,t,n;DreamConfig.website_time&&(e=document.getElementById("webCopyright"),t=(new Date).getFullYear(),n=new Date(DreamConfig.website_time).getFullYear(),e.innerText=t!==n?"© "+n+"-"+t:"© "+t)},initTimeCount(){if($(".timelife").length&&o!==(new Date).getHours()){var e=[{title:"今日已经过去",endTitle:"小时",num:0,percent:"0%"},{title:"这周已经过去",endTitle:"天",num:0,percent:"0%"},{title:"本月已经过去",endTitle:"天",num:0,percent:"0%"},{title:"今年已经过去",endTitle:"个月",num:0,percent:"0%"}],t=(+new Date-new Date((new Date).toLocaleDateString()).getTime())/1e3/60/60,i=(o=t)/24*100,t=(e[0].num=parseInt(t),e[0].percent=parseInt(i)+"%",{0:7,1:1,2:2,3:3,4:4,5:5,6:6}[(new Date).getDay()]),i=t/7*100,t=(e[1].num=parseInt(t),e[1].percent=parseInt(i)+"%",(new Date).getFullYear()),i=(new Date).getDate(),a=(new Date).getMonth()+1,t=i/new Date(t,a,0).getDate()*100,a=(e[2].num=i,e[2].percent=parseInt(t)+"%",(new Date).getMonth()+1),i=a/12*100;e[3].num=a,e[3].percent=parseInt(i)+"%";let n="";e.forEach((e,t)=>{n+=` +(()=>{window.encrypt=e=>window.btoa(unescape(encodeURIComponent(e))),window.decrypt=e=>decodeURIComponent(escape(window.atob(e)));const t={initWidget(){var e=$(".columns .column-right"),t=$(".columns .column-right-shadow");if(e.length&&t.length&&!t[0].children.length)for(const n of e[0].children)t[0].append(n.cloneNode(!0))},initTocAndNotice(){var e=location["pathname"],t=(window.tocPjax&&window.tocPjax(),0===$(".widget.toc .card-content ul").length),e="toc"===DreamConfig.notice_show_mode&&!t||"index"===DreamConfig.notice_show_mode&&"/"!==e;t?$(".widget.toc,.action-toc").addClass("is-hidden-all"):$(".widget.toc,.action-toc").removeClass("is-hidden-all"),e?$(".widget.notice").addClass("is-hidden-all"):$(".widget.notice").removeClass("is-hidden-all")},initBanner(){const i=$(".banner-info-desc");if(0!==i.length){const o=i.text();i.text("");let t,n="",a=!0;const s=function(){var e=n.length;a&&e
${this.alt&&DreamConfig.show_img_name?`

${this.alt}

`:""}`)})},initMode(){let t=localStorage.getItem("night")||!1;const n=e=>{e?$("html").addClass("color-scheme-dark").removeClass("color-scheme-light").addClass("night"):$("html").addClass("color-scheme-light").removeClass("color-scheme-dark").removeClass("night"),localStorage.setItem("night",e),t=e};$("#toggle-mode").on("click",()=>n("true"!==t.toString())),"system"===DreamConfig.default_theme?window.matchMedia("(prefers-color-scheme: dark)").addListener(e=>n(e.matches)):n("true"===t.toString())},initNavbar(){var t=$(".navbar-nav a"),e=$(".panel-side-menu .link");let n=0;var{href:a,pathname:i}=location;if(i&&"/"!==i)for(let e=0;e$(this).addClass("active"),()=>$(this).removeClass("active")):($(this).on("click",function(e){e.stopPropagation(),$(this).toggleClass("active"),$(document).one("click",()=>$(this).removeClass("active")),e.stopPropagation()}),n.on("click",e=>e.stopPropagation()))})},iniTaskItemDisabled(){$('li[data-type="taskItem"]').each(function(){$(this).find('label > input[type="checkbox"]').prop("disabled",!0)})},initLogonMenu(){$(".navbar-logon").each(function(e,t){"hover"===($(t).attr("trigger")||"click")?$(this).hover(()=>$(this).addClass("active"),()=>$(this).removeClass("active")):$(this).on("click",function(e){e.stopPropagation(),$(this).toggleClass("active"),$(document).one("click",()=>$(this).removeClass("active")),e.stopPropagation()})})},initScroll(){window.initTop=0,document.addEventListener("scroll",()=>{const e=$(document).scrollTop(),t=(i=e>window.initTop,window.initTop=e,i),n=$("body"),a=$(".actions");var i;50e.preventDefault),$(".navbar .toc-content").on("click",function(e){e.stopPropagation(),$("html").removeClass("disable-scroll"),$(".navbar-mask").removeClass("active slideout"),$(".navbar-slideout").removeClass("active slideout-toc")})},sideMenuMobile(){$(".navbar-slideout-menu .current").parents(".panel-body").show().siblings(".panel").addClass("in"),$(".navbar-slideout-menu .panel").on("click",function(e){e.stopPropagation();var e=$(this),t=e.parent().parent();t.find(".panel").not(e).removeClass("in"),t.find(".panel-body").not(e.siblings(".panel-body")).stop().hide("fast"),e.toggleClass("in").siblings(".panel-body").stop().toggle("fast")})},initEvent(){var e=$("body");function n(e){var e=$(e),t=e.attr("data-close");return t&&""!==t.trim()?e.closest(t.trim()):e}e.on("click",".click-close",function(e){e.stopPropagation(),n(this).remove()}),e.on("click",".click-animation-close",function(e){e.stopPropagation();let t=n(this);t.addClass("close-animation"),setTimeout(()=>t.remove(),300)})},offscreenTip(){if(!Utils.isMobile()&&(DreamConfig.document_hidden_title||DreamConfig.document_visible_title)){let e=document.title,t=null;document.addEventListener("visibilitychange",function(){document.hidden?(DreamConfig.document_visible_title&&document.title===DreamConfig.document_visible_title||(e=document.title),DreamConfig.document_hidden_title&&(document.title=DreamConfig.document_hidden_title),clearTimeout(t)):(document.title=DreamConfig.document_visible_title||e,DreamConfig.document_visible_title&&(t=setTimeout(function(){document.title===DreamConfig.document_visible_title&&(document.title=e)},2e3)))})}},initCarousel(){window.Swiper&&new Swiper(".swiper",{loop:!0,parallax:!0,effect:"slide",spaceBetween:10,speed:600,autoplay:{delay:3e3,disableOnInteraction:!1,pauseOnMouseEnter:!0},pagination:{el:".swiper-pagination",clickable:!0},navigation:{nextEl:".swiper-button-next",prevEl:".swiper-button-prev"}})},sparkInput(){const n=DreamConfig.spark_input_content&&DreamConfig.spark_input_content.filter(e=>0sparkInput(t,[t.innerText,...n]))})},loveTime(){let c=$(".love .love-time");if(0!==c.length){var e=c.attr("data-time");if(/^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}$/.test(e)){const d=new Date(e);setInterval(function(){var e=Date.now(),t=parseInt((e-d)/1e3),n=t%60,a=(t=parseInt(t/60))%60;let i=(t=parseInt(t/60))%24,o=parseInt(t/24),s=0,r=d.getFullYear(),l=e.getFullYear();for(;r${o}天${i}${a}${n}秒`},300)}}},webCopyright(){var e,t,n;DreamConfig.website_time&&(e=document.getElementById("webCopyright"),t=(new Date).getFullYear(),n=new Date(DreamConfig.website_time).getFullYear(),e.innerText=t!==n?"© "+n+"-"+t:"© "+t)},initTimeCount(){if($(".timelife").length&&o!==(new Date).getHours()){var e=[{title:"今日已经过去",endTitle:"小时",num:0,percent:"0%"},{title:"这周已经过去",endTitle:"天",num:0,percent:"0%"},{title:"本月已经过去",endTitle:"天",num:0,percent:"0%"},{title:"今年已经过去",endTitle:"个月",num:0,percent:"0%"}],t=(+new Date-new Date((new Date).toLocaleDateString()).getTime())/1e3/60/60,a=(o=t)/24*100,t=(e[0].num=parseInt(t),e[0].percent=parseInt(a)+"%",{0:7,1:1,2:2,3:3,4:4,5:5,6:6}[(new Date).getDay()]),a=t/7*100,t=(e[1].num=parseInt(t),e[1].percent=parseInt(a)+"%",(new Date).getFullYear()),a=(new Date).getDate(),i=(new Date).getMonth()+1,t=a/new Date(t,i,0).getDate()*100,i=(e[2].num=a,e[2].percent=parseInt(t)+"%",(new Date).getMonth()+1),a=i/12*100;e[3].num=i,e[3].percent=parseInt(a)+"%";let n="";e.forEach((e,t)=>{n+=`
${e.title} @@ -11,4 +11,4 @@
${e.percent}
- `}),$(".aside-timelife").html(n)}},initSecurityLink(){DreamConfig.enable_security_link&&DreamConfig.security_link_url&&0!==DreamConfig.security_link_url.length&&$(document).on("click","a[target=_blank]",e=>{e.preventDefault();var t,e=$(e.currentTarget).attr("href"),n=window.location.hostname;window.open("_blank").location=(n=n,t=(t=e).toLowerCase().trim(),n=n.toLowerCase().trim(),t.startsWith("//")?t=window.location.protocol+t:t.startsWith("/")&&(t=window.location.origin+t),(t=t.startsWith("http://")||t.startsWith("https://")?t.replace(/\/$/,""):t).includes(n)?e:DreamConfig.security_link_url+"?target="+encodeURIComponent(e))})},initGrayMode(){var e,t,n;(!0===DreamConfig.gray_mode||"custom"===DreamConfig.gray_mode&&(e=Date.now(),t=new Date(DreamConfig.gray_mode_start_time).getTime(),n=new Date(DreamConfig.gray_mode_end_time).getTime(),t<=e)&&e<=n)&&$("html").addClass("gray-mode")},initEffects(){Utils.isMobile()||(DreamConfig.cursor_move&&Utils.cachedScript(`${DreamConfig.theme_base}/js/cursor/move/${DreamConfig.cursor_move}.min.js?mew=`+DreamConfig.theme_version),DreamConfig.cursor_click&&Utils.cachedScript(`${DreamConfig.theme_base}/js/cursor/click/${DreamConfig.cursor_click}.min.js?mew=`+DreamConfig.theme_version),DreamConfig.enable_live2d&&Utils.cachedScript(DreamConfig.theme_base+"/js/autoload.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_lantern_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/lantern.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_sakura_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/sakura.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_snowflake_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/snowflake.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_universe_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/universe.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_circle_magic_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/circleMagic.min.js?mew="+DreamConfig.theme_version))},showThemeVersion(){DreamConfig.enable_console_version_info&&window.logger(`%c页面加载耗时:${Math.round(performance.now())}ms | Theme By Dream2 Plus `+DreamConfig.theme_version,"color:#fff; background: linear-gradient(270deg, #986fee, #8695e6, #68b7dd, #18d7d3); padding: 8px 15px; border-radius: 0 15px 0 15px")}};window.commonContext=t;let o=-1;{const n=["initCarousel","sparkInput","websiteTime"],i=["initEffects","showThemeVersion","iniTaskItemDisabled"];Object.keys(t).forEach(e=>!n.includes(e)&&!i.includes(e)&&t[e]()),document.addEventListener("DOMContentLoaded",function(){$("html").addClass("loaded"),n.forEach(e=>t[e]&&t[e]())}),window.addEventListener("load",function(){i.forEach(e=>t[e]&&t[e]()),$("html").addClass("ready")})}})(); \ No newline at end of file + `}),$(".aside-timelife").html(n)}},initSecurityLink(){DreamConfig.enable_security_link&&DreamConfig.security_link_url&&0!==DreamConfig.security_link_url.length&&$(document).on("click","a[target=_blank]",e=>{e.preventDefault();var t,e=$(e.currentTarget).attr("href"),n=window.location.hostname;window.open("_blank").location=(n=n,t=(t=e).toLowerCase().trim(),n=n.toLowerCase().trim(),t.startsWith("//")?t=window.location.protocol+t:t.startsWith("/")&&(t=window.location.origin+t),(t=t.startsWith("http://")||t.startsWith("https://")?t.replace(/\/$/,""):t).includes(n)?e:DreamConfig.security_link_url+"?target="+encodeURIComponent(e))})},initGrayMode(){var e,t,n;(!0===DreamConfig.gray_mode||"custom"===DreamConfig.gray_mode&&(e=Date.now(),t=new Date(DreamConfig.gray_mode_start_time).getTime(),n=new Date(DreamConfig.gray_mode_end_time).getTime(),t<=e)&&e<=n)&&$("html").addClass("gray-mode")},initEffects(){Utils.isMobile()||(DreamConfig.cursor_move&&Utils.cachedScript(`${DreamConfig.theme_base}/js/cursor/move/${DreamConfig.cursor_move}.min.js?mew=`+DreamConfig.theme_version),DreamConfig.cursor_click&&Utils.cachedScript(`${DreamConfig.theme_base}/js/cursor/click/${DreamConfig.cursor_click}.min.js?mew=`+DreamConfig.theme_version),DreamConfig.enable_live2d&&Utils.cachedScript(DreamConfig.theme_base+"/js/autoload.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_lantern_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/lantern.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_sakura_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/sakura.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_snowflake_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/snowflake.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_universe_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/universe.min.js?mew="+DreamConfig.theme_version),DreamConfig.effects_circle_magic_mode&&Utils.cachedScript(DreamConfig.theme_base+"/js/effects/circleMagic.min.js?mew="+DreamConfig.theme_version))},showThemeVersion(){DreamConfig.enable_console_version_info&&window.logger(`%c页面加载耗时:${Math.round(performance.now())}ms | Theme By Dream2 Plus `+DreamConfig.theme_version,"color:#fff; background: linear-gradient(270deg, #986fee, #8695e6, #68b7dd, #18d7d3); padding: 8px 15px; border-radius: 0 15px 0 15px")}};window.commonContext=t;let o=-1;{const n=["initCarousel","sparkInput","websiteTime"],a=["initEffects","showThemeVersion","iniTaskItemDisabled"];Object.keys(t).forEach(e=>!n.includes(e)&&!a.includes(e)&&t[e]()),document.addEventListener("DOMContentLoaded",function(){$("html").addClass("loaded"),n.forEach(e=>t[e]&&t[e]())}),window.addEventListener("load",function(){a.forEach(e=>t[e]&&t[e]()),$("html").addClass("ready")})}})(); \ No newline at end of file diff --git a/templates/assets/js/mew-custom.min.js b/templates/assets/js/mew-custom.min.js index bd5b844..c08d232 100644 --- a/templates/assets/js/mew-custom.min.js +++ b/templates/assets/js/mew-custom.min.js @@ -12,4 +12,4 @@
${this.options.value}
`,this.drawComplete()}}),customElements.define("mew-panel",class extends i{init(){this.options={title:this.getAttribute("title")||"",color:this.getAttribute("color")||"var(--theme)"},this.innerHTML=`
${this.options.title}
-
${this.innerHTML}
`,this.style.background=this.options.color,this.style.color=this.options.color,this.drawComplete()}}),customElements.define("mew-message",class extends i{init(){this.options={type:/^(success|info|warning|error)$/.test(this.getAttribute("type"))?this.getAttribute("type"):"info",content:this.innerHTML||"消息内容"},this.innerHTML=this.options.content,this.setAttribute("type",this.options.type),this.drawComplete()}}),customElements.define("mew-hr",class extends i{init(){this.startColor=this.getAttribute("startColor")||"#01d0ff",this.endColor=this.getAttribute("endColor")||"#fc3e85",this.style.backgroundImage=`repeating-linear-gradient(-45deg, ${this.startColor} 0,${this.startColor} 20%, transparent 0,transparent 35%, ${this.endColor} 0,${this.endColor} 65%, transparent 0,transparent 80%, ${this.startColor} 0,${this.startColor} 100%)`,this.drawComplete()}}),customElements.define("mew-timeline",class extends i{init(){let t="",i=this.firstChild;for(;i;){var e;"MEW-TIMELINE-TITLE"===i.tagName?t+=`
${i.innerHTML}
`:"MEW-TIMELINE-ITEM"===i.tagName&&(i.getAttribute("type"),e=i.getAttribute("title")?`${i.getAttribute("title")}`:"",t+=`
${e}
${i.innerHTML}
`),i=i.nextElementSibling}this.innerHTML=t,this.drawComplete()}}),customElements.define("mew-btn",class extends i{init(){this.options={color:this.getAttribute("color")||"var(--theme)",href:this.getAttribute("href"),target:this.getAttribute("target")||"_blank",icon:this.getAttribute("icon")},this.innerHTML=`${this.options.icon?``:""}${this.innerHTML}`;var t=this.querySelector("a.mew-btn");this.options.href&&(t.href=this.options.href,t.target=this.options.target),this.drawComplete()}}),customElements.define("mew-quote",class extends i{init(){this.options={avatar:this.getAttribute("avatar"),href:this.getAttribute("href"),name:this.getAttribute("name")};var t=this.options.avatar?``:"",i=this.options.name?`${this.options.name}`:"";this.innerHTML=`
${t}

${this.innerHTML}

${i}
`,this.drawComplete()}}),customElements.define("mew-link",class extends i{async init(){this.options={img:this.getAttribute("img"),href:this.getAttribute("href")||"",title:this.getAttribute("title"),slug:this.getAttribute("slug"),id:this.getAttribute("id"),type:this.getAttribute("type")||"post",desc:this.innerHTML},(this.options.id||this.options.slug)&&await Utils.request({url:this.options.id?`/api/content/${this.options.type}s/`+this.options.id:`/api/content/${this.options.type}s/slug?slug=`+this.options.slug,method:"GET"}).then(t=>{this.options.img=this.options.img||t.thumbnail,this.options.href=this.options.title||t.fullPath,this.options.title=this.options.title||t.title,this.options.desc=this.options.desc||t.summary}).catch(t=>{this.options.desc="Error: "+t});var t=this.options.img?``:"",i=this.options.desc?`${this.options.desc}`:`${this.options.href}`;this.innerHTML=`

${this.options.title||"我分享了一个网站"}

${i}
${t}
`,this.drawComplete()}}),customElements.define("mew-video",class extends i{init(){this.options={src:this.getAttribute("src"),type:this.getAttribute("type"),autoplay:this.hasAttribute("autoplay")&&"false"!==this.getAttribute("autoplay"),controls:"false"!==this.getAttribute("controls"),loop:this.hasAttribute("loop")&&"false"!==this.getAttribute("loop"),muted:this.hasAttribute("muted")&&"false"!==this.getAttribute("muted"),preload:this.hasAttribute("preload")&&"false"!==this.getAttribute("preload"),poster:this.getAttribute("poster"),width:/^\d{1,3}%$/.test(this.getAttribute("width"))?this.getAttribute("width"):"100%"},this.innerHTML=``,this.drawComplete()}}),customElements.define("mew-photos",class t extends i{init(){$.fn.justifiedGallery?this.render():t.prototype.load?t.prototype.await.push(()=>this.render()):(t.prototype.load=!0,t.prototype.await=[],new Promise(t=>{Utils.cachedScript("https://unpkg.com/justifiedGallery@3.8.1/dist/js/jquery.justifiedGallery.min.js").done(()=>t()).fail(()=>t())}).then(()=>{this.render(),t.prototype.await&&t.prototype.await.forEach(t=>t())}))}render(){this.options={captions:this.hasAttribute("captions")&&"false"!==this.getAttribute("captions"),margins:this.getAttribute("margins")||"4"},$(this).find("img").each((t,i)=>{$(i).wrap(`
`)}),$(this).justifiedGallery({captions:this.options.captions,margins:this.options.margins}),this.drawComplete()}}),customElements.define("mew-raw",class extends i{init(){var t=this.innerHTML;this.innerHTML="",this.attachShadow({mode:"closed"}).innerHTML=t,this.drawComplete()}})})})(); \ No newline at end of file +
${this.innerHTML}
`,this.style.background=this.options.color,this.style.color=this.options.color,this.drawComplete()}}),customElements.define("mew-message",class extends i{init(){this.options={type:/^(success|info|warning|error)$/.test(this.getAttribute("type"))?this.getAttribute("type"):"info",content:this.innerHTML||"消息内容"},this.innerHTML=this.options.content,this.setAttribute("type",this.options.type),this.drawComplete()}}),customElements.define("mew-hr",class extends i{init(){this.startColor=this.getAttribute("startColor")||"#01d0ff",this.endColor=this.getAttribute("endColor")||"#fc3e85",this.style.backgroundImage=`repeating-linear-gradient(-45deg, ${this.startColor} 0,${this.startColor} 20%, transparent 0,transparent 35%, ${this.endColor} 0,${this.endColor} 65%, transparent 0,transparent 80%, ${this.startColor} 0,${this.startColor} 100%)`,this.drawComplete()}}),customElements.define("mew-timeline",class extends i{init(){let t="",i=this.firstChild;for(;i;){var e;"MEW-TIMELINE-TITLE"===i.tagName?t+=`
${i.innerHTML}
`:"MEW-TIMELINE-ITEM"===i.tagName&&(i.getAttribute("type"),e=i.getAttribute("title")?`${i.getAttribute("title")}`:"",t+=`
${e}
${i.innerHTML}
`),i=i.nextElementSibling}this.innerHTML=t,this.drawComplete()}}),customElements.define("mew-btn",class extends i{init(){this.options={color:this.getAttribute("color")||"var(--theme)",href:this.getAttribute("href"),target:this.getAttribute("target")||"_blank",icon:this.getAttribute("icon")},this.innerHTML=`${this.options.icon?``:""}${this.innerHTML}`;var t=this.querySelector("a.mew-btn");this.options.href&&(t.href=this.options.href,t.target=this.options.target),this.drawComplete()}}),customElements.define("mew-quote",class extends i{init(){this.options={avatar:this.getAttribute("avatar"),href:this.getAttribute("href"),name:this.getAttribute("name")};var t=this.options.avatar?``:"",i=this.options.name?`${this.options.name}`:"";this.innerHTML=`
${t}

${this.innerHTML}

${i}
`,this.drawComplete()}}),customElements.define("mew-link",class extends i{async init(){this.options={img:this.getAttribute("img"),href:this.getAttribute("href")||"",title:this.getAttribute("title"),slug:this.getAttribute("slug"),id:this.getAttribute("id"),type:this.getAttribute("type")||"post",desc:this.innerHTML},(this.options.id||this.options.slug)&&await Utils.request({url:this.options.id?`/api/content/${this.options.type}s/`+this.options.id:`/api/content/${this.options.type}s/slug?slug=`+this.options.slug,method:"GET"}).then(t=>{this.options.img=this.options.img||t.thumbnail,this.options.href=this.options.title||t.fullPath,this.options.title=this.options.title||t.title,this.options.desc=this.options.desc||t.summary}).catch(t=>{this.options.desc="Error: "+t});var t=this.options.img?``:"",i=this.options.desc?`${this.options.desc}`:`${this.options.href}`;this.innerHTML=`

${this.options.title||"我分享了一个网站"}

${i}
${t}
`,this.drawComplete()}}),customElements.define("mew-video",class extends i{init(){this.options={src:this.getAttribute("src"),type:this.getAttribute("type"),autoplay:this.hasAttribute("autoplay")&&"false"!==this.getAttribute("autoplay"),controls:"false"!==this.getAttribute("controls"),loop:this.hasAttribute("loop")&&"false"!==this.getAttribute("loop"),muted:this.hasAttribute("muted")&&"false"!==this.getAttribute("muted"),preload:this.hasAttribute("preload")&&"false"!==this.getAttribute("preload"),poster:this.getAttribute("poster"),width:/^\d{1,3}%$/.test(this.getAttribute("width"))?this.getAttribute("width"):"100%"},this.innerHTML=``,this.drawComplete()}}),customElements.define("mew-photos",class t extends i{init(){$.fn.justifiedGallery?this.render():t.prototype.load?t.prototype.await.push(()=>this.render()):(t.prototype.load=!0,t.prototype.await=[],new Promise(t=>{Utils.cachedScript("https://unpkg.com/justifiedGallery@3.8.1/dist/js/jquery.justifiedGallery.min.js").done(()=>t()).fail(()=>t())}).then(()=>{this.render(),t.prototype.await&&t.prototype.await.forEach(t=>t())}))}render(){this.options={captions:this.hasAttribute("captions")&&"false"!==this.getAttribute("captions"),margins:this.getAttribute("margins")||"4"},$(this).find("img").each((t,i)=>{$(i).wrap(`
`)}),$(this).justifiedGallery({captions:this.options.captions,margins:this.options.margins}),this.drawComplete()}}),customElements.define("mew-raw",class extends i{init(){var t=this.innerHTML;this.innerHTML="",this.attachShadow({mode:"closed"}).innerHTML=t,this.drawComplete()}})})})(); \ No newline at end of file diff --git a/templates/photos.html b/templates/photos.html index 9b76d8d..340b8a0 100644 --- a/templates/photos.html +++ b/templates/photos.html @@ -11,7 +11,7 @@