mirror of
https://ghfast.top/https://github.com/zsjy/halo-theme-dream2.0-plus.git
synced 2025-03-15 02:43:08 +08:00
1 line
4.1 KiB
JavaScript
1 line
4.1 KiB
JavaScript
(()=>{let t=!1,s={},e=!1,n=!1,c={page:0,size:15,sort:"createTime,desc"};const i=(i,t)=>{e=!0,i.addClass("loading"),t&&t.team&&(t.team=t.team.substring(2));const o={...c,...t||{}};s.promise=new Promise((a,e)=>{s.abort=e,Utils.request({url:"/api/content/photos",method:"GET",data:o}).then(t=>a(t)).catch(t=>e(t))}).then(t=>{var a,e=t.content||[];n=0===e.length||(a=i,e=e.reduce((t,a,e)=>`${t}<div href="${a.url}" data-fancybox="gallery" data-caption="${a.description||a.name||""}"><img width="100%" height="100%" src="${a.thumbnail}" alt="${a.name||""}"/><div class="info"><div><svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M834.9 913.6H189.7c-69.2 0-125.5-56.3-125.5-125.5V381.5c0-69.2 56.3-125.5 125.5-125.5h14.7c14.4 0 27.3-8.6 32.9-21.8l19.2-45.1c19.7-46.3 65-76.3 115.4-76.3h280.6c50.4 0 95.7 30 115.4 76.3l19.2 45c5.7 13.2 18.6 21.8 33 21.8h14.7c69.2 0 125.5 56.3 125.5 125.5V788c0.1 69.3-56.2 125.6-125.4 125.6z m-645.2-568c-19.8 0-35.8 16.1-35.8 35.8V788c0 19.8 16.1 35.8 35.8 35.8h645.2c19.8 0 35.8-16.1 35.8-35.8V381.5c0-19.8-16.1-35.8-35.8-35.8h-14.7c-50.4 0-95.7-30-115.4-76.3l-19.2-45c-5.6-13.2-18.6-21.8-33-21.8H372c-14.4 0-27.3 8.6-33 21.8l-19.2 45c-19.7 46.3-65 76.3-115.4 76.3h-14.7z"></path><path d="M512.3 742.8c-97.4 0-176.6-79.2-176.6-176.6s79.2-176.6 176.6-176.6 176.6 79.2 176.6 176.6-79.2 176.6-176.6 176.6z m0-263.6c-48 0-87 39-87 87s39 87 87 87 87-39 87-87-39-87-87-87z"></path></svg><p>${a.name}</p></div>${a.location?`<div><svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M511.3 960.8c-9.3 0-18.6-2.9-26.5-8.7-14.1-10.4-345.6-256.4-345.6-516.1 0-205.2 166.9-372.1 372.1-372.1S883.4 230.8 883.4 436c0 259.7-331.5 505.8-345.6 516.1-7.8 5.8-17.2 8.7-26.5 8.7z m0-807.2c-155.7 0-282.4 126.7-282.4 282.4 0 176.5 207.5 361.8 282.4 422.9 74.9-61.1 282.4-246.4 282.4-422.9 0-155.8-126.7-282.4-282.4-282.4z"></path><path d="M511.3 611.7c-96.9 0-175.7-78.8-175.7-175.7s78.8-175.7 175.7-175.7S687.1 339.1 687.1 436s-78.9 175.7-175.8 175.7z m0-261.8c-47.5 0-86.1 38.6-86.1 86.1s38.6 86.1 86.1 86.1 86.1-38.6 86.1-86.1-38.6-86.1-86.1-86.1z"></path></svg><p>${a.location}</p></div>`:""}<div><svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M512.7 959.8c-247 0-448-201-448-448s201-448 448-448 448 201 448 448-200.9 448-448 448z m0-806.4c-197.6 0-358.4 160.8-358.4 358.4s160.8 358.4 358.4 358.4 358.4-160.8 358.4-358.4-160.7-358.4-358.4-358.4z"></path><path d="M700 576.8H512.7c-24.6 0-44.6-19.9-44.8-44.5L466 254.5c-0.2-24.7 19.8-44.9 44.5-45.1h0.3c24.6 0 44.6 19.9 44.8 44.5l1.6 233.3H700c24.7 0 44.8 20.1 44.8 44.8 0 24.7-20.1 44.8-44.8 44.8z"></path></svg><p>${Utils.formatDate(a.takeTime)}</p></div>${a.description?`<p>${a.description}</p>`:""}</div></div>`,""),a.append(e),a.justifiedGallery({rowHeight:200,maxRowHeight:!1,maxRowsCount:0,sizeRangeSuffixes:{},lastRow:"nojustify",captions:!1,waitThumbnailsLoad:!0,margins:10,extension:/\.(jpe?g|png|gif|bmp|webp)$/,cssAnimation:!1}),t.isLast)}).catch(t=>console.log(t)).finally(()=>{i.removeClass("loading"),s={},e=!1})},o={initEvent(){t||($("body").on("click",".photos-teams .item",function(t){t.stopPropagation();t=$(this);t.hasClass("active")||(t.addClass("active").siblings("li").removeClass("active"),(async(t,a)=>{s&&(s.abort&&s.abort("abort"),await s.promise),t.empty(),n=!1,e=!1,c.page=0,location.hash=a.team,i(t,a)})($(".photos-gallery"),{team:t.attr("data-team")}))}),window.addEventListener("scroll",function(){var t=$(".photos-gallery");0!==t.length&&$(window).scrollTop()+$(window).height()>=t.height()&&(e||n||(c.page++,i(t,{team:$(".photos-teams li.active").attr("data-team")})))}),t=!0)},initPhotos(){var t,a=$(".photos-gallery");s={},e=!1,n=!1,c={page:0,size:15,sort:"createTime,desc"},location.hash?(t=decodeURI(location.hash.substring(1)),0<(t=$(".photos-teams li[data-team="+t+"]")).length?t.click():$(".photos-teams li:not([data-team])").addClass("active")&&i(a)):($(".photos-teams li:not([data-team])").addClass("active"),i(a))}};window.photoPjax=function(a){0!==$(".photos-gallery").length&&Object.keys(o).forEach(t=>window.pjaxSerialNumber===a&&o[t]())},window.pjaxSerialNumber||o.initEvent(),window.pjaxSerialNumber||o.initPhotos()})(); |