index.ec15a070.js 6.8 KB

1
  1. import{d as r,f as p,as as g,c as e,ar as A,J as h,C as d,at as n}from"./vendor.63aa8b19.js";import{o as m,g as y,i as f}from"./index.07dfb936.js";const S="_colUpload_1er9j_1",K="_uploadFileMusic_1er9j_4",U="_uploadSection_1er9j_8",E="_uploadFile_1er9j_4",w="_fileUpload_1er9j_32",C="_uploadClass_1er9j_47";var s={colUpload:S,uploadFileMusic:K,uploadSection:U,uploadFile:E,fileUpload:w,uploadClass:C},c="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAwCAYAAABqkJjhAAAAAXNSR0IArs4c6QAABdZJREFUaEPNmktwU1UYx//n3pt3H/RFk1ZpS4HSloaxRaCCyEZHXcmArlyAMi6ccRx1YUfrOIwKDMowg47o4KOCuhAcXDjiuFBEZ3wgoKQtlDYQoknTtDRJ2zwakhzn3DS1Ja+TJk38lvd+j9/95tzzffc7lyCJmAIjjSRCdlASeYgADRTEAEoVyfQzva5XFEFFJJwYuQgQcouADgO4TihOE0lxcmf1OnMin+T2i33UqUcg8noEZCcoFTMF4dWfB3ybESEIE6AHkti9a+l6x9zb84D7gmMbaCh8ioIaeAMvVC8V8KxPQoaJQLc9oe/8LXZtFliGDYfOUAr1QiEyseMCBkCAAERsjUHLwGwZUD+9kI/Mxh6KF1jWJ2RYkIR2tjyiwH7HBxGKJzPJULa6GQEDEAg+3FXTuZuw3QAUA4v5giV6OL1UBLUg4Qu2S3AIexEFUdFEen3OFyki+zlscqpSKWlRJenwyfDv3H4FoIuY/I4zoLiP2ypHijpBiQZVGb4e64czOMHllRD8SHr9jhuUYhmXRY6VVqgq4AsH8dXoJS7PhMBKTP6RYC4rGFfkGSUNkbBcVQ6zfwxn3QkL23x3rCKafA6aSZBc65aJGhgUxfBGguj3OmAPeOAK+ZKGKTgwI1MSEbWKEuhEZdp8/C+AY5QSBKgECSKJa3FmHyTvwN5wCPaAH/ZpL+zTfjRoi7CxtCptZmMKiwbsvhWEbdoLmwzngy3gg23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CB9kKACYSugh0ZZAxMSBgETQU7lMkUmB3KtGr0uwt27JUJMAEZJhrS3kqWRo+9mOT7YJEXmBAEiChtbVVWyqehBTu65QGWMyuJ22KwccBypvN0OJ4SmJCwANoDtdDNlsFc3aSj7sX+/WAe8MzvB1T+/UA4TQV6sk1dnfCU5l/GnbWW8dlbMwAAAABJRU5ErkJggg==",F="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAAAXNSR0IArs4c6QAAAilJREFUWEfNmM1qE1EUx39hUBTd1FZFaBfdhZqFhbaIdSXooi+SkKF5gnalTxCZkLyKbm2RVrCLVLJzIxRtq5uKpWVo+cPcMr1m5s40TbkXZhHuuef8cj7ux6lQftwGHgEPgbvAneSTpuPk+wfsA7+AkzImKiWEnwCzwAOg6Loz4DfwHdgrYquIYgHMARNFFObI/AG+JYCZYnlAmnuaeGVElkvL5a1dQN77b2QB3QIWgKnrJEnpOgC+AKe2/mFAgnkJ3B8TjFF7BHyyoWwg/X4+Rs/Y/1Ge+pwOnw1UG0POuBytnOoboTSQqmnZtXpM8xum+tJAyptRS/uqvNoSlE8XG5w2PVVV5giCgCiKluI4Pmu1WttxHOcal3y73V4MgqAShuGWSz6puj3joRfAZJ6Fbre7VK/X1yQzGAw+1mq191lGBNPv91er1epryfd6vXeNRmPL4b5DYFNAOpveuI6DKIoWm83mulGaBWXDSL7T6bwNw3DbAaSN8oOAZoBnruAPM2RDFZFx2NkR0Dww7QLSfJ5BzafDVCS0Q2z+EJAzf9ILs6AkY3LmijBadiigV8C9Ih4yMsOg0utdSZ9j66+AVhSNMkBZ4RvBM8Z87CWQdyHzLqm9K3ufNsavXh4dKjlnHt3k4Sog764fgvLqgiYg766wgvLqki8g755BgvLqoWhOXa+e0gbKq2ZD+nrkTTvGvrN507CywfRsepw0JPJaemok/Czb0jsHTl1iZ73DWaEAAAAASUVORK5CYII=",B=r({name:"col-upload",props:{modelValue:{type:String,default:""},type:{type:String,default:""},uploadType:{type:String,default:"image"},disabled:{type:Boolean,default:!1},bucket:{type:String,default:"daya"},size:{type:Number,default:5},accept:{type:String,default:".png,.jpg,.jpeg"},tips:{type:String,default:"\u8BF7\u4E0A\u4F20\u56FE\u7247"},extraTips:{type:String,default:"\u56FE\u7247\u6700\u5927\u4E0D\u80FD\u8D85\u8FC75MB"},onChange:{type:Function,default:()=>({})},onRemove:{type:Function,default:()=>({})},btnText:{type:String,default:"\u4E0A\u4F20\u6587\u4EF6"}},data(){return{ossUploadUrl:`https://${this.bucket}.ks3-cn-beijing.ksyuncs.com/`,dataObj:{policy:"",signature:"",key:"",KSSAccessKeyId:"",acl:"public-read",name:""},fileList:[],loading:null}},methods:{async handleSuccess(l){var t;try{const o={policy:l.data.policy,signature:l.data.signature,key:l.data.key,KSSAccessKeyId:l.data.kssAccessKeyId,acl:"public-read",name:l.data.key,file:l.file},a=await m(this.ossUploadUrl,o);this.$emit("update:modelValue",a),this.onChange(a)}catch{}(t=this.loading)==null||t.close()},handleRemove(){console.log("remove")},handleChange(){console.log("handleChange")},handleProgress(){console.log("handleProgress")},handleError(){var l;(l=this.loading)==null||l.close()},async beforeUpload(l){console.log(l);let t=!0;if(this.size&&(t=l.size/1024/1024<this.size,!t))return p.error(`\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7${this.size}M!`),!1;this.loading=g.service({target:this.$refs.uploadDom,lock:!0,fullscreen:!1,text:"\u4E0A\u4F20\u4E2D...",background:"rgba(0, 0, 0, 0.7)"}),console.log(this.loading);try{const o=l.name.replaceAll(" ","_"),a=new Date().getTime()+o,u={filename:a,bucketName:this.bucket,postData:{filename:a,acl:"public-read",key:a}},{data:i}=await y(u);this.dataObj={policy:i.policy,signature:i.signature,key:a,KSSAccessKeyId:i.kssAccessKeyId,acl:"public-read",name:a}}catch{this.loading.close()}},fileName(l=""){return l.split("/").pop()},handleExceed(){}},render(){return e("div",{class:[s.colUpload,"w-full"]},[e(A,{disabled:this.disabled,action:this.ossUploadUrl,data:this.dataObj,httpRequest: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",class:this.uploadType==="file"?s.fileUpload:"",style:{lineHeight:"0"}},{default:()=>[e("div",{ref:"uploadDom",class:[s.uploadClass,"w-full"],style:{height:this.uploadType==="image"?"85px":"48px"}},[this.modelValue?this.uploadType==="image"?e(h,{src:this.modelValue,fit:"cover",class:s.uploadSection},null):e("div",{class:[s.uploadFile,this.disabled&&"cursor-not-allowed"]},[e(d,{size:20},{default:()=>[this.type==="music"?e("img",{src:c},null):e(n,null,null)]}),e("span",{class:"whitespace-nowrap overflow-hidden text-ellipsis flex-1",style:{lineHeight:"1.2"}},[this.fileName(this.modelValue)]),!this.disabled&&e(d,{size:18,style:"margin-right: 0;",class:"ml-1 cursor-pointer"},{default:()=>[e("img",{src:F,onClick:l=>{l.stopPropagation(),this.$emit("update:modelValue",""),this.onRemove()}},null)]})]):this.uploadType==="image"?e("div",{class:[s.uploadSection,"flex items-center flex-col justify-center"]},[e("img",{src:f,class:"w-8 h-7 mb-3"},null),e("p",null,[this.tips])]):e("div",{class:[s.uploadFile,this.type==="music"?s.uploadFileMusic:""]},[e(d,{size:20},{default:()=>[this.type==="music"?e("img",{src:c},null):e(n,null,null)]}),this.btnText])])]}),e("p",{class:"text-3 text-[#999999] leading-6 pt-1"},[this.extraTips])])}});export{B as C};