Files
corner/assets/Photo-PUo06Yg2.js
T

2 lines
2.5 KiB
JavaScript

import{d as w,h as m,e as k,G as C,a as i,b as n,F as c,r as f,p as T,A as x,o as l,_ as E}from"./index-Cxw7RuVO.js";const P={class:"outer-grid"},$=["onClickCapture","id"],j=["src","alt"],z={class:"photo-abs-container",absolute:"","inset-0":"",flex:"","justify-center":"","items-center":""},B=["src","alt"],R=w({__name:"Photo",setup(A){function d(e){return Array.from(e).reduce((t,o)=>(t+o.charCodeAt(0)*65535)%22859,0)/22859}async function g(e,t=100){return new Promise(o=>{const s=()=>{const a=e();a?o(a):setTimeout(s,t)};s()})}const u=C(),r=m([]),h=m([]),_={1:0,2:.3,3:.5},y=async()=>{r.value=await(await fetch("https://p.aza.moe/photos")).json(),r.value.sort((o,s)=>o.exif.DateTime<s.exif.DateTime?1:-1);const e=[];let t=[];r.value.forEach(o=>{t.length===0?t.push(o):t.length>=3?(e.push(t),t=[o]):d(o.original_photo)<_[t.length]?(e.push(t),t=[o]):t.push(o)}),t.length>0&&e.push(t),h.value=e},p=e=>(e=e.replace("data/photos","static").replace("./",""),`https://p.aza.moe/${e}`),v=e=>`rotate(${d(e)*20-10}deg)`,b=async(e,t)=>{console.log("Clicked photo:",e.id);const o=t.currentTarget,s=o.querySelector(".photo-wrapper");s.style.viewTransitionName=`photo-${e.id}`,await document.startViewTransition(()=>{o.classList.toggle("active"),document.getElementsByClassName("blur")[0].toggleAttribute("hidden")}).finished,s.style.viewTransitionName=""};return k(async()=>{await y(),u.params.id&&(await g(()=>document.getElementById(`photo-${u.params.id}`))).click()}),(e,t)=>(l(),i(c,null,[t[0]||(t[0]=n("div",{class:"title"},[n("div",{class:"font-script-en bold"},"The Wandering Gallery"),n("div",{class:"subtitle <sm:hidden"},"想要把旅行中用相机拍到好看照片时的喜悦分享给幸运的路人,所以买了便携照片打印机、搭了这个网页!")],-1)),n("div",P,[(l(!0),i(c,null,f(h.value,o=>(l(),i("div",{key:o[0].id,flex:"","justify-center":"",class:T(`grid-cols-${o.length}`)},[(l(!0),i(c,null,f(o,s=>(l(),i("div",{key:s.id,onClickCapture:async a=>await b(s,a),class:"img-container","cursor-pointer":"",id:`photo-${s.id}`},[n("img",{class:"photo","w-full":"","h-full":"","object-contain":"","opacity-0":"",src:p(s.thumbnail_edited),alt:s.id},null,8,j),n("div",z,[n("div",{class:"photo-wrapper",style:x({transform:v(s.id)})},[n("img",{class:"photo","w-full":"","object-contain":"",src:p(s.thumbnail_edited),alt:s.id},null,8,B)],4)])],40,$))),128))],2))),128))]),t[1]||(t[1]=n("div",{class:"blur",hidden:"","pos-fixed":"","inset-0":"","backdrop-blur-sm":"","z-5":""},null,-1))],64))}}),D=E(R,[["__scopeId","data-v-5be140d4"]]);export{D as default};