25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

2 satır
1.8KB

  1. var l=(e,t,a)=>new Promise((n,o)=>{var d=s=>{try{r(a.next(s))}catch(c){o(c)}},i=s=>{try{r(a.throw(s))}catch(c){o(c)}},r=s=>s.done?n(s.value):Promise.resolve(s.value).then(d,i);r((a=a.apply(e,t)).next())});import{m as b,E as m,n as U}from"./index.551f5afa.js";const v=(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 R(n.response.data.id)).url}))},x=e=>{m.error(e.message?JSON.parse(e.message):"\u4E0A\u4F20\u5931\u8D25\uFF01")},E=(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(i=>{const r=new FileReader,s=new Image;s.onload=c=>{const g=document.createElement("canvas"),u=g.getContext("2d"),p=s.width*.5,h=s.height*.5;g.width=p,g.height=h,u.clearRect(0,0,p,h),u.drawImage(s,0,0,p,h);const w=g.toDataURL(e.type),y=F(w,e.type);i(y)},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})},R=(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,$=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:`${U.defaults.baseURL}/file/thumbnail/download?fileId=${a}`,response:{data:{id:a}}}})))),t};export{x as a,B as b,R as d,E as f,$ as g,v as h};