index.592965d4.js 4.6 KB

1
  1. import{d as A,T as u,s as h,e as b,bh as v,bo as f,p as U,a$ as D,i as a,N as p,b as w,F as y}from"./index.6b776f4b.js";import"./index.7cc0b0e7.js";import"./index.570314c1.js";import"./index.bf33b691.js";import{U as z}from"./index.87f67876.js";const V="_uploader_22hbs_1",R="_uploaderText_22hbs_53",k="_uploadImg_22hbs_58";var d={"uploader-section":"_uploader-section_22hbs_1","img-close":"_img-close_22hbs_9","col-uploader":"_col-uploader_22hbs_24",uploader:V,uploaderText:R,uploadImg:k},g="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAAAyCAMAAAAz3ZgNAAAAAXNSR0IArs4c6QAAAV9QTFRFAAAA////////qqqq////v7+/29vb39/fzMzM5ubm6Ojo1dXV6urq6+vr39/f4+Pj5OTk3t7e4ODg4eHh29vb4+Pj3d3d4+Pj4eHh4uLi3d3d3t7e3t7e39/f4ODg3d3d3t7e39/f4ODg39/f3Nzc3d3d39/f4ODg3t7e4eHh39/f3t7e39/f3t7e3t7e4ODg3t7e3d3d39/f39/f39/f4ODg39/f3d3d3t7e39/f3d3d3t7e4ODg3t7e39/f3t7e3t7e3d3d4ODg39/f3d3d3t7e3t7e39/f3d3d39/f3t7e3t7e39/f3d3d3t7e3t7e3t7e39/f3t7e3d3d39/f3t7e3t7e39/f39/f39/f3t7e3t7e3t7e3t7e39/f3t7e39/f3t7e39/f3t7e3t7e3d3d39/f39/f3t7e3t7e3t7e3t7e3t7e3t7e3t7e3d3d3t7e3t7e3t7e39/f3t7eiTfdtAAAAHR0Uk5TAAECAwMEBwgKCgsMDA0QEhMXISIjJCUlKiwtLi8wMTQ2Nzk/QUxPU1RUWF5gY2RrbG9vcHFydnh7f4CCi5GRkpWYoqWnqaqur6+ztLW2t7i5ubq9vr/BxsfW2Nna293e3uPk5+nr7e7x8/X29/j5+vr9/v6jM+nnAAABy0lEQVRIx+3WZ1PCQBAG4AURG6gQu6goIPaGvVcQewEbYi9YUND9/2M4owFySS7nB8cZ309LZp/hkmxmFsBY/PGH7RrgjSeNiBdlOddq5+NJ1Mzb3U6XKdO6TH62Z+vhV2TJll3sjZCyP0sPIWOOCgGi+Vx4YeU4SuGzzBpDFH7C4BJTDSVms9lE4c/6Oub87lZwff0kjonQN0BySq4ESd3fUSrz5EJbua11jjIAMwDd9Lk4r/7iV+7PwzRdKpq84HhUOdiuxJPur5tpUvyRAD61+0pKfEF+GHP5Pc3gUuNxibfJvDW/JwCwRNdpv8TLZW7LbzqzgmVoLRrJ5P7zTWbKaGTFAwwcFwv03rvW4RH3G3S41qMT8368EVoNj8ncHM7hWi+O9slYMHdoNcaGhWsMrZIPKDlDNgG2SNEDxRw8BjBIDloFdRwcG8Eizt9jN8AkD98X58flcwA4EzwcF63E1MSQi+NZoFnwzjwhJ5fzz/8QD17+iHcVjdxKZYqHA9gnEqQ84OMAldPizF7X83IAR19vBfDz7PwufzbAO5X8xABvUXIDi9lNoZIbWAvHaUtygFUfWqlL9nCKSe9VqCzp+gt5+mbdb6LRD+7pAfpKTznkAAAAAElFTkSuQmCC",E=A({name:"ColUploadVideo",props:{modelValue:String,posterUrl:String,tips:{type:String,default:"\u70B9\u51FB\u4E0A\u4F20"},nativeUpload:{type:Boolean,default:!0},size:{type:Number,default:30},deletable:{type:Boolean,default:!0},bucket:{type:String,default:"daya"}},methods:{beforeRead(t){return t.size/1024/1024<this.size?!0:(u(`\u4E0A\u4F20\u89C6\u9891\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${this.size}MB`),!1)},beforeDelete(t,r){return!0},async afterRead(t,r){try{t.status="uploading",t.message="\u4E0A\u4F20\u4E2D...";const l=h.platformType==="TEACHER"?"/api-teacher/getUploadSign":"/api-student/getUploadSign",e=t.file.name.replaceAll(" ","_"),o=new Date().getTime()+e;console.log(t);const s=await b.post(l,{data:{filename:e,bucketName:this.bucket,postData:{filename:e,acl:"public-read",key:o,unknowValueField:[]}}});u.loading({message:"\u52A0\u8F7D\u4E2D...",forbidClick:!0,loadingType:"spinner",duration:0});const i={policy:s.data.policy,signature:s.data.signature,key:o,KSSAccessKeyId:s.data.kssAccessKeyId,acl:"public-read",name:e};let n=new FormData;for(let c in i)n.append(c,i[c]);n.append("file",t.file),await v(f(this.bucket),{method:"POST",data:n});const m=f(this.bucket)+o;u.clear(),this.$emit("update:modelValue",m)}catch(l){console.log(l)}},onClose(t){this.$emit("update:modelValue",null),t.stopPropagation()},onNativeUpload(){U({api:"chooseFile",content:{type:"video",bucket:this.bucket}},t=>{this.$emit("update:modelValue",t.fileUrl)})},getVideoBase64(t){return new Promise(function(r){let l="";const e=document.createElement("video");e.setAttribute("crossOrigin","anonymous"),e.setAttribute("src",t),e.setAttribute("preload","auto"),e.addEventListener("loadeddata",function(){console.log(e,"video loadeddata");const o=document.createElement("canvas");console.log("video.clientWidth",e.videoWidth),console.log("video.clientHeight",e.videoHeight);const s=e.videoWidth||750,i=e.videoHeight||500;o.width=s,o.height=i,o.getContext("2d").drawImage(e,0,0,s,i),l=o.toDataURL("image/jpeg"),r(l)})})}},render(){return D(()=>this.modelValue),a("div",{class:d["uploader-section"]},[this.modelValue&&this.deletable?a(p,{name:"cross",onClick:this.onClose,class:d["img-close"]},null):null,w().isApp&&this.nativeUpload?a("div",{onClick:this.onNativeUpload,style:{height:"100%"}},[this.modelValue?a("video",{ref:"videoUpload",class:d.uploadImg,src:this.modelValue+"#t=1,4"},null):a("div",{class:d.uploader},[a(p,{name:g,size:"32"},null),a("p",{class:d.uploaderText},[this.tips])])]):a(y,null,[a(z,{accept:".mp4",afterRead:this.afterRead,beforeRead:this.beforeRead,beforeDelete:this.beforeDelete},{default:()=>this.modelValue?a("video",{ref:"videoUpload",class:d.uploadImg,src:this.modelValue+"#t=1,4"},null):a("div",{class:d.uploader},[a(p,{name:g,size:"32"},null),a("p",{class:d.uploaderText},[this.tips])])})])])}});export{E as C};