index.b7fa29fb.js 5.2 KB

1
  1. import{r as L}from"./index.ebd578f0.js";import{d as r,E as d,ah as p,c as s,ag as u,k as h}from"./vendor.f5bf56e4.js";const m="_uploadSection_1doix_1",q="_uploadFile_1doix_11",f="_fileUpload_1doix_25",g="_uploadClass_1doix_25",A="_disabled_1doix_48";var l={uploadSection:m,uploadFile:q,fileUpload:f,uploadClass:g,disabled:A},b="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAAAyCAMAAAAz3ZgNAAAAAXNSR0IArs4c6QAAAX1QTFRFAAAAAP8AAP//AP+AAP//AKqqVaqqVf+qAL+AJNu2IL+fM8yZM8yzLtG5Kr+qKtWqJ8SxMM+vK8aqKMmuLMixLsmqLcutLMWoK8aqKcisK8iqLsuoLcaqLMisK8moMMqqL8usLMmsL8aqLsesLcmqLcaqK8ipLMaoLMarLcWoLsisLsWqLsiqLsWrLsirLsmrLceqLMaqLserLcisLcaqLMaqLsiqLsaoLsirLcmsLceqLcerLciqLseqLMerLMepLcapLsirLsepLsirLcepLMepLcipLsiqLceqLMepLcerLciqLceqLciqLserLciqLceqLceqLceqLMiqLMaqLcirLceqLsaqLsiqLceqLciqLciqLciqLceqLciqLcepLceqLciqLMeqLMeqLcirLceqLciqLcerLciqLceqLceqLceqLcerLMepLceqLceqLMeqLcaqLceqLceqLceqLcaqLceqLcerLceqLcepLceqLMiqLceqLcirLceqsuDHzwAAAH50Uk5TAAEBAgIDAwMEBwgKCgsMDA0QEhMXISIjJCUqLC0uLzAxNDY3OT9BTExPU1RUWFheYGNka2xvb3BwcXJ2eHt/gIKLkZGSlZiipaepqq6vs7S1tre4ubm6vb6/wcbH1tjZ2dna293e3uPj5Ofp6evt7vHz9fb3+Pj4+fr6/f7+i9OX2AAAAdNJREFUSMft1mdTwkAQBuBVQcVeELvYCxbsir1gF3sBGyr2imBH97cbzmggOZLL+cFxxvfTcrMPuSTLcAD6YvPdrRYCb2pCiHiSEbVWOOF7RNW83aw1x4dbZ8jHhkjteEGWrGQJvW5SdkTobmTMTjKAR84tz6wc+yl8nFnjPIXvMTj/SEmawWCIp/B7be3N++5WcG0dFMbE0t5JckhW5kjd0Zgu8afJ6uzMKidlAMYA7A/ULz4u+OLnlZ+bsZ4qmmrBHIixsXWRP1V+3YxVcX0L1Me6rweRT0oPwynvKYeyWNwn8mqJV8l7egGm6TpkE3m2xDPlTUcmMHYveNzh3JKVg3Dpcc/WAAPHKaPWe1fbPOJmiQZXe3RC3neX5l2uAYknuKK42ouj/WSSMHpoVcaGxhNlXGVolbxTyRmyDLBCilZI5eBegC4yqvlQxMGxFIzC/AXsAMM8fFOYn7I6M0Cen4fjlOnzj2EfuTge9ZZbaseCyMml/PM/xOfOfsRbUvquxfKVhwNkDflJucXHAXJHhZm9KOblAOb2thzg55H5XX6vgzcp+Z4OXqHkOg5ml8lKruNYOEg7JPew6m0T9ZDteGXSGzkxDunaB/LQ1aItjkY/AA/7Wc4JL6xFAAAAAElFTkSuQmCC",x=r({name:"col-upload-video",props:{modelValue:{type:String,default:""},disabled:{type:Boolean,default:!1},bucket:{type:String,default:"daya"},multiple:{type:Boolean,default:!1},limit:{type:Number,default:1},size:{type:Number,default:800},accept:{type:String,default:".mp4"},tips:{type:String,default:"\u8BF7\u4E0A\u4F20\u89C6\u9891"},extraTips:{type:String,default:"\u89C6\u9891\u6700\u5927\u4E0D\u80FD\u8D85\u8FC7800MB"},multipleModel:{type:Function,default:e=>{}}},data(){return{ossUploadUrl:`https://${this.bucket}.ks3-cn-beijing.ksyuncs.com/`,dataObj:{policy:"",signature:"",key:"",KSSAccessKeyId:"",acl:"public-read",name:""},fileList:[],tempUrls:{},responseList:[],btnLoading:!1,loading:null}},methods:{handleSuccess(e,t,a){var i;if((i=this.loading)==null||i.close(),console.log(this.fileList,"fileList"),console.log(e,t,a,"response"),this.multiple)t.status==="success"&&this.responseList.push(this.tempUrls[t.uid]),a.length===this.responseList.length&&(this.btnLoading=!1,this.multipleModel(this.responseList),this.responseList=[],this.fileList=[]);else{const o=this.ossUploadUrl+this.dataObj.key;this.$emit("update:modelValue",o)}},handleRemove(){console.log("remove")},handleChange(){console.log("handleChange")},handleProgress(e){console.log("handleProgress",e)},handleError(){var e;this.btnLoading=!1,(e=this.loading)==null||e.close()},async beforeUpload(e){var a;console.log(e);let t=!0;if(this.size&&(t=e.size/1024/1024<this.size,!t))return d.error(`\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7${this.size}M!`),!1;this.multiple?this.btnLoading=!0:this.loading=p.service({target:this.$refs.uploadDom,lock:!0,fullscreen:!1,text:"\u4E0A\u4F20\u4E2D...",background:"rgba(0, 0, 0, 0.7)"});try{let i=e.name.replaceAll(" ","_"),o=new Date().getTime()+i,n={filename:i,bucketName:this.bucket,postData:{filename:i,acl:"public-read",key:o,unknowValueField:[]}};const{data:c}=await L.post("/api-website/getUploadSign",{data:n});this.dataObj={policy:c.policy,signature:c.signature,key:o,KSSAccessKeyId:c.kssAccessKeyId,acl:"public-read",name:i},this.tempUrls[e.uid]=this.ossUploadUrl+this.dataObj.key}catch{this.btnLoading=!1,(a=this.loading)==null||a.close()}},fileName(e=""){return e.split("/").pop()},handleExceed(e){if(e.length>this.limit)return d.error(`\u4E00\u6B21\u6027\u6700\u591A\u53EA\u80FD\u4E0A\u4F20${this.limit}\u4E2A\u6587\u4EF6`),!1}},render(){return s("div",{class:[l.colUpload,"w-full"]},[s(u,{disabled:this.disabled||this.btnLoading,action:this.ossUploadUrl,data:this.dataObj,onSuccess:this.handleSuccess,onRemove:this.handleRemove,onChange:this.handleChange,onProgress:this.handleProgress,onError:this.handleError,fileList:this.fileList,showFileList:!1,accept:this.accept,beforeUpload:this.beforeUpload,onExceed:this.handleExceed,ref:"uploadRef",multiple:this.multiple,limit:this.limit,class:[this.multiple&&l.fileUpload,this.disabled&&l.disabled],style:{lineHeight:"0"}},{default:()=>[s("div",{ref:"uploadDom",class:[l.uploadClass,"w-full"],style:{height:this.multiple?"40px":"85px"}},[this.modelValue?s("video",{ref:"videoUpload",crossorigin:"anonymous",class:l.uploadSection,src:this.modelValue},null):this.multiple?s(h,{size:"large",type:"primary",loading:this.btnLoading},{default:()=>[this.btnLoading?"\u4E0A\u4F20\u4E2D...":"\u70B9\u51FB\u4E0A\u4F20"]}):s("div",{class:[l.uploadSection,"flex items-center flex-col justify-center"]},[s("img",{src:b,class:"w-8 h-7 mb-3"},null),s("p",null,[this.tips])])])]}),!this.multiple&&s("p",{class:"text-3 text-[#999999] leading-6 pt-1"},[this.extraTips])])}});export{x as C};