share-C5-oqXHU.js 2.2 KB

1
  1. import"./modulepreload-polyfill-B5Qt9EMX.js";import{F as y,l as f,d as w,e as x,P as b,B as L,h as k,i as I,W as z,j as P,k as m,n as R}from"./WorkLayer-5uUyxw6h.js";document.body.onload=function(){function o(c){const e=/\/share\/([\w-]+)/,i=c.match(e);return i?i[1]:null}let t=window.location.href;console.log("current url:",t);let n=t.substring(0,t.indexOf("/share")),a=o(t);console.log("host:",n),console.log("id:",a);let r=new URLSearchParams(window.location.search).get("uuid");if(!r)return;a||(a="test");let s=`${n}/proxy/zips/v2/number_mini/1501/${a}.zip`;n.includes("art.pcoloring.com")&&(s=`https://pcoloring.com/zips/v2/number_mini/1501/${a}.zip`),B(a,r,s)};async function B(o,t,n){if(console.log(o,t,n),!t)return;let a=await S(o,t);if(!a||a.length<=0)return;let l=document.querySelector("#play-button"),r=document.querySelector("#canvas"),s=r.getContext("webgl2",{premultipliedAlpha:!1}),c=window.devicePixelRatio;r.width=r.clientWidth*c,r.height=r.clientHeight*c;let e=new y(s,c),i;o=="test"?i=await $():i=await f(n),l.style.zIndex="200";let h={hintStyle:"default",sound:!0,vibrate:!0,autoNext:!0,...JSON.parse(localStorage.getItem("settings")||"{}")},d=new w(new x(h),i,s,a);e.fillerData=d,console.log("resource",i),e.setContentPadding(new b(0,0,0,0));let u=d.width,g=d.height;e.setContentSize(u,g),i.bg&&e.addLayer(new L(e,i.bg,e.width,e.height,k.Repeat)),e.addLayer(new I(e,0,0,u,g));let p=new z(e,d);e.addLayer(p),e.addLayer(new P(e,i.page,u,g)),p.initTask(),l.addEventListener("click",()=>v(p))}async function S(o,t){let n=null;const a=`/api/tasks?uuid=${t}&art=${o}`;try{const l=await fetch(a,{method:"GET",headers:{"Content-Type":"application/json"}});return l.ok?(console.log("获取task数据成功:"),n=await l.json()):console.error("未获取到task数据"),n}catch(l){console.error("网络请求或服务器错误:",l)}}async function $(){let o="/assets/unzipped/friend",t=[fetch(`${o}/config.json`).then(e=>e.json()),m(`${o}/page.png`),m(`${o}/map.png`),m("/assets/fonts/numbers_roboto_500.png")],[n,a,l,r,s,c]=await Promise.all(t);return new R(n,a,l,r,[],c,s)}async function v(o){let t=document.getElementById("poster-img");t.style.zIndex="0";let n=document.getElementById("play-button");n.style.zIndex="0",await o.replay(),n.style.zIndex="200"}