index.5299bdd3.js 4.4 KB

1
  1. import{d as p,T as n,br as f,n as g,bf as A,j as o,N as u,f as m,F as h}from"./ResizeObserver.es.b7226882.js";import"./index.20c0f4c5.js";import"./index.cf00521e.js";import"./index.e4fc81ba.js";import{g as b,o as v,U}from"./index.52126c22.js";const D="_uploader_22hbs_1",w="_uploaderText_22hbs_53",z="_uploadImg_22hbs_58";var l={"uploader-section":"_uploader-section_22hbs_1","img-close":"_img-close_22hbs_9","col-uploader":"_col-uploader_22hbs_24",uploader:D,uploaderText:w,uploadImg:z},c="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",k=p({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:(n(`\u4E0A\u4F20\u89C6\u9891\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${this.size}MB`),!1)},beforeDelete(t,s){return!0},async afterRead(t,s){try{t.status="uploading",t.message="\u4E0A\u4F20\u4E2D...";const d=t.file.name.replaceAll(" ","_"),e=new Date().getTime()+d;console.log(t);const{data:a}=await b({filename:e,bucketName:this.bucket,postData:{filename:e,acl:"public-read",key:e}},!0);setTimeout(()=>{n.loading({message:"\u52A0\u8F7D\u4E2D...",forbidClick:!0,loadingType:"spinner",duration:0})},100);const i={policy:a.policy,signature:a.signature,key:e,KSSAccessKeyId:a.kssAccessKeyId,acl:"public-read",name:e,file:t.file},r=await v(f(this.bucket),i);n.clear(),this.$emit("update:modelValue",r)}catch(d){console.log(d)}},onClose(t){this.$emit("update:modelValue",null),t.stopPropagation()},onNativeUpload(){g({api:"chooseFile",content:{type:"video",bucket:this.bucket}},t=>{this.$emit("update:modelValue",t.fileUrl)})},getVideoBase64(t){return new Promise(function(s){let d="";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 a=document.createElement("canvas");console.log("video.clientWidth",e.videoWidth),console.log("video.clientHeight",e.videoHeight);const i=e.videoWidth||750,r=e.videoHeight||500;a.width=i,a.height=r,a.getContext("2d").drawImage(e,0,0,i,r),d=a.toDataURL("image/jpeg"),s(d)})})}},render(){return A(()=>this.modelValue),o("div",{class:l["uploader-section"]},[this.modelValue&&this.deletable?o(u,{name:"cross",onClick:this.onClose,class:l["img-close"]},null):null,m().isApp&&this.nativeUpload?o("div",{onClick:this.onNativeUpload,style:{height:"100%"}},[this.modelValue?o("video",{ref:"videoUpload",class:l.uploadImg,src:this.modelValue+"#t=1,4"},null):o("div",{class:l.uploader},[o(u,{name:c,size:"32"},null),o("p",{class:l.uploaderText},[this.tips])])]):o(h,null,[o(U,{accept:".mp4",afterRead:this.afterRead,beforeRead:this.beforeRead,beforeDelete:this.beforeDelete},{default:()=>this.modelValue?o("video",{ref:"videoUpload",class:l.uploadImg,src:this.modelValue+"#t=1,4"},null):o("div",{class:l.uploader},[o(u,{name:c,size:"32"},null),o("p",{class:l.uploaderText},[this.tips])])})])])}});export{k as C};