123456789101112131415161718192021222324 |
- ;(function(){function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}var __vite_style__=document.createElement('style');__vite_style__.innerHTML="._colUpload_or6a6_1{line-height:0}._uploadSection_or6a6_4{width:150px;height:85px;background:#f8faf9;border-radius:10px;border:1px solid rgba(45,199,170,.26);font-size:14px;color:#2dc7aa;line-height:20px}._uploadFile_or6a6_14{width:100%;min-width:300px;height:50px;border:1px solid rgba(142,142,142,.26);border-radius:10px;display:flex;align-items:center;padding:0 15px;color:var(--el-text-color-regular)}._uploadFile_or6a6_14 .el-icon{margin-right:5px}._fileUpload_or6a6_28 .el-upload--text{width:100%}._fileUpload_or6a6_28 .el-loading-spinner{display:flex;align-items:center;height:42px!important;justify-content:center;margin-top:-20px!important}._fileUpload_or6a6_28 .el-loading-spinner svg{width:20px;height:20px;margin-right:5px}._uploadClass_or6a6_43{height:85px;width:100%}._uploadClass_or6a6_43 .el-loading-spinner{margin-top:-33px;height:85px}._uploadClass_or6a6_43 .el-loading-mask{height:50px;border-radius:10px}\n";document.head.appendChild(__vite_style__);System.register(['./vendor-legacy.7f609859.js','./index-legacy.76f0d13f.js'],function(exports){'use strict';var defineComponent,ElMessage,ElLoading,createVNode,ElUpload,ElImage,ElIcon,document_default,createTextVNode,onOnlyFileUpload,getUploadSign,iconUpload;return{setters:[function(module){defineComponent=module.d;ElMessage=module.E;ElLoading=module.ai;createVNode=module.c;ElUpload=module.ah;ElImage=module.x;ElIcon=module.l;document_default=module.aj;createTextVNode=module.a;},function(module){onOnlyFileUpload=module.o;getUploadSign=module.g;iconUpload=module.i;}],execute:function execute(){var colUpload="_colUpload_or6a6_1";var uploadSection="_uploadSection_or6a6_4";var uploadFile="_uploadFile_or6a6_14";var fileUpload="_fileUpload_or6a6_28";var uploadClass="_uploadClass_or6a6_43";var styles={colUpload:colUpload,uploadSection:uploadSection,uploadFile:uploadFile,fileUpload:fileUpload,uploadClass:uploadClass};var ColUpload=exports('C',defineComponent({name:'col-upload',props:{modelValue:{type:String,default:''},uploadType:{type:String,default:'image'},disabled:{type:Boolean,default:false},bucket:{type:String,default:'daya'},size:{type:Number,default:5// 默认5M
- },accept:{type:String,default:'.png,.jpg,.jpeg'},tips:{type:String,default:'请上传图片'},extraTips:{type:String,default:'图片最大不能超过5MB'},onChange:{type:Function,default:function _default(){}}},data:function data(){return{// ossUploadUrl: 'https://ks3-cn-beijing.ksyuncs.com/' + this.bucket,
- ossUploadUrl:"https://".concat(this.bucket,".ks3-cn-beijing.ksyuncs.com/"),dataObj:{policy:'',signature:'',key:'',KSSAccessKeyId:'',acl:'public-read',name:''},fileList:[],loading:null};},methods:{handleSuccess:function handleSuccess(info){var _this=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee(){var _this$loading;var obj,url;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_context.prev=0;obj={policy:info.data.policy,signature:info.data.signature,key:info.data.key,KSSAccessKeyId:info.data.kssAccessKeyId,acl:'public-read',name:info.data.key,file:info.file};_context.next=4;return onOnlyFileUpload(_this.ossUploadUrl,obj);case 4:url=_context.sent;// console.log(url)
- _this.$emit('update:modelValue',url);_this.onChange(url);_context.next=11;break;case 9:_context.prev=9;_context.t0=_context["catch"](0);case 11:(_this$loading=_this.loading)===null||_this$loading===void 0?void 0:_this$loading.close();case 12:case"end":return _context.stop();}}},_callee,null,[[0,9]]);}))();},handleRemove:function handleRemove(){console.log('remove');},handleChange:function handleChange(){console.log('handleChange');},handleProgress:function handleProgress(){console.log('handleProgress');},handleError:function handleError(){var _this$loading2;(_this$loading2=this.loading)===null||_this$loading2===void 0?void 0:_this$loading2.close();},beforeUpload:function beforeUpload(file){var _this2=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee2(){var isLt2M,fileName,key,obj,_yield$getUploadSign,data;return regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:// beforeUpload
- console.log(file);// let fileType = true
- // if (props.rules.type && props.rules.type.length > 0) {
- // const fileExtension = file.name.split('.').pop().toUpperCase()
- // console.log(
- // props.rules.type,
- // fileExtension,
- // props.rules.type.indexOf(fileExtension) != -1
- // )
- // if (props.rules.type.indexOf(fileExtension) != -1) {
- // fileType = true
- // } else {
- // fileType = false
- // ElMessage.error('请上传正确的文件!')
- // return false
- // }
- // }
- isLt2M=true;if(!_this2.size){_context2.next=7;break;}isLt2M=file.size/1024/1024<_this2.size;if(isLt2M){_context2.next=7;break;}ElMessage.error("\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7".concat(_this2.size,"M!"));return _context2.abrupt("return",false);case 7:_this2.loading=ElLoading.service({target:_this2.$refs.uploadDom,lock:true,fullscreen:false,text:'上传中...',background:'rgba(0, 0, 0, 0.7)'});console.log(_this2.loading);_context2.prev=9;fileName=file.name.replaceAll(' ','_');key=new Date().getTime()+fileName;obj={filename:key,bucketName:_this2.bucket,postData:{filename:key,acl:'public-read',key:key}};// const { data } = await request.post('/api-website/getUploadSign', {
- // data: obj
- // })
- _context2.next=15;return getUploadSign(obj);case 15:_yield$getUploadSign=_context2.sent;data=_yield$getUploadSign.data;_this2.dataObj={policy:data.policy,signature:data.signature,key:key,KSSAccessKeyId:data.kssAccessKeyId,acl:'public-read',name:key};_context2.next=23;break;case 20:_context2.prev=20;_context2.t0=_context2["catch"](9);_this2.loading.close();case 23:case"end":return _context2.stop();}}},_callee2,null,[[9,20]]);}))();},fileName:function fileName(){var name=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return name.split('/').pop();},handleExceed:function handleExceed(){}},render:function render(){var _this3=this;return createVNode("div",{"class":[styles.colUpload,'w-full']},[createVNode(ElUpload,{"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":false,"accept":this.accept,"beforeUpload":this.beforeUpload,"onExceed":this.handleExceed,"ref":"uploadRef","class":this.uploadType==='file'?styles.fileUpload:'',"style":{lineHeight:'0'}},{default:function _default(){return[createVNode("div",{"ref":"uploadDom","class":[styles.uploadClass,'w-full'],"style":{height:_this3.uploadType==='image'?'85px':'48px'}},[_this3.modelValue?_this3.uploadType==='image'?createVNode(ElImage,{"src":_this3.modelValue,"fit":"cover","class":styles.uploadSection},null):createVNode("div",{"class":styles.uploadFile},[createVNode(ElIcon,null,{default:function _default(){return[createVNode(document_default,null,null)];}}),createVNode("span",{"class":"whitespace-nowrap overflow-hidden text-ellipsis","style":{lineHeight:'1.2'}},[_this3.fileName(_this3.modelValue)])]):_this3.uploadType==='image'?createVNode("div",{"class":[styles.uploadSection,'flex items-center flex-col justify-center']},[createVNode("img",{"src":iconUpload,"class":"w-8 h-7 mb-3"},null),createVNode("p",null,[_this3.tips])]):createVNode("div",{"class":styles.uploadFile},[createVNode(ElIcon,null,{default:function _default(){return[createVNode(document_default,null,null)];}}),createTextVNode("\u4E0A\u4F20\u6587\u4EF6")])])];}}),createVNode("p",{"class":"text-3 text-[#999999] leading-6 pt-1"},[this.extraTips])]);}}));}};});})();
|