| 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 R,k as m,n as B}from"./WorkLayer-5uUyxw6h.js";document.body.onload=function(){function o(c){const e=/\/share\/([\w-]+)/,r=c.match(e);return r?r[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);const l=new URLSearchParams(window.location.search);let i=l.get("u")||l.get("uuid");if(!i)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`),P(a,i,s)};async function P(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"),i=document.querySelector("#canvas"),s=i.getContext("webgl2",{premultipliedAlpha:!1}),c=window.devicePixelRatio;i.width=i.clientWidth*c,i.height=i.clientHeight*c;let e=new y(s,c),r;o=="test"?r=await $():r=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),r,s,a);e.fillerData=d,console.log("resource",r),e.setContentPadding(new b(0,0,0,0));let u=d.width,g=d.height;e.setContentSize(u,g),r.bg&&e.addLayer(new L(e,r.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 R(e,r.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,i,s,c]=await Promise.all(t);return new B(n,a,l,i,[],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"}
|