Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

2 rindas
1.8KB

  1. var l=(e,t,a)=>new Promise((n,o)=>{var d=s=>{try{r(a.next(s))}catch(c){o(c)}},p=s=>{try{r(a.throw(s))}catch(c){o(c)}},r=s=>s.done?n(s.value):Promise.resolve(s.value).then(d,p);r((a=a.apply(e,t)).next())});import{m as b,E as m}from"./index.a7edfbd5.js";const x=(e,t,a)=>{if(e.code!==200){m.error(e.data.message?e.data.message:"\u4E0A\u4F20\u5931\u8D25!");const n=t.findIndex(o=>o.response.code!==200);t.splice(n,1)}a&&t.length>1&&t.shift(),t.forEach(n=>l(void 0,null,function*(){n.url=(yield w(n.response.data.id)).url}))},E=e=>{m.error(e.message?JSON.parse(e.message):"\u4E0A\u4F20\u5931\u8D25\uFF01")},I=(e,{types:t,size:a})=>{const n=e.type==="image/jpeg"||e.type==="image/png",o=t.indexOf(e.type)!==-1,d=a?e.size/1024<=a:!0;return o||m.error("\u4E0A\u4F20\u6587\u4EF6\u683C\u5F0F\u9519\u8BEF!"),e.size/1024/1024>5&&n?new Promise(p=>{const r=new FileReader,s=new Image;s.onload=c=>{const g=document.createElement("canvas"),u=g.getContext("2d"),i=s.width*.5,h=s.height*.5;g.width=i,g.height=h,u.clearRect(0,0,i,h),u.drawImage(s,0,0,i,h);const y=g.toDataURL(e.type),U=F(y,e.type);p(U)},r.onload=c=>{s.src=c.target.result},r.readAsDataURL(e)}):(d||m.error(`\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${a>=1024?a/1024:a}${a>=1024?"MB":"KB"}!`),o&&d)},F=(e,t)=>{for(var a=atob(e.split(",")[1]),n=[],o=0;o<a.length;o++)n.push(a.charCodeAt(o));return new Blob([new Uint8Array(n)],{type:t})},w=(e,t)=>l(void 0,null,function*(){const a=yield b({fileId:e});return t?a:{filename:a.filename,url:URL.createObjectURL(a)}}),B=e=>e!=null&&e.length?e.map(t=>t.response.data.id):void 0,D=e=>{let t=[];return e!=null&&e.length&&(t=Promise.all(e.map((a,n)=>l(void 0,null,function*(){return{name:`${new Date().getTime()+n}`,url:(yield w(a)).url,response:{data:{id:a}}}})))),t};export{E as a,B as b,w as d,I as f,D as g,x as h};