|
@@ -1,8 +1,8 @@
|
|
<template>
|
|
<template>
|
|
<div>
|
|
<div>
|
|
<el-upload
|
|
<el-upload
|
|
- action="http://macro-oss.oss-cn-shenzhen.aliyuncs.com"
|
|
|
|
- :data="dataObj"
|
|
|
|
|
|
+ :action="useOss?ossUploadUrl:minioUploadUrl"
|
|
|
|
+ :data="useOss?dataObj:null"
|
|
list-type="picture-card"
|
|
list-type="picture-card"
|
|
:file-list="fileList"
|
|
:file-list="fileList"
|
|
:before-upload="beforeUpload"
|
|
:before-upload="beforeUpload"
|
|
@@ -44,7 +44,10 @@
|
|
host: ''
|
|
host: ''
|
|
},
|
|
},
|
|
dialogVisible: false,
|
|
dialogVisible: false,
|
|
- dialogImageUrl:null
|
|
|
|
|
|
+ dialogImageUrl:null,
|
|
|
|
+ useOss:true, //使用oss->true;使用MinIO->false
|
|
|
|
+ ossUploadUrl:'http://macro-oss.oss-cn-shenzhen.aliyuncs.com',
|
|
|
|
+ minioUploadUrl:'http://localhost:8080/minio/upload',
|
|
};
|
|
};
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -73,6 +76,10 @@
|
|
},
|
|
},
|
|
beforeUpload(file) {
|
|
beforeUpload(file) {
|
|
let _self = this;
|
|
let _self = this;
|
|
|
|
+ if(!this.useOss){
|
|
|
|
+ //不使用oss不需要获取策略
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
policy().then(response => {
|
|
policy().then(response => {
|
|
_self.dataObj.policy = response.data.policy;
|
|
_self.dataObj.policy = response.data.policy;
|
|
@@ -89,7 +96,12 @@
|
|
})
|
|
})
|
|
},
|
|
},
|
|
handleUploadSuccess(res, file) {
|
|
handleUploadSuccess(res, file) {
|
|
- this.fileList.push({url: file.name,url:this.dataObj.host + '/' + this.dataObj.dir + '/' + file.name});
|
|
|
|
|
|
+ let url = this.dataObj.host + '/' + this.dataObj.dir + '/' + file.name;
|
|
|
|
+ if(!this.useOss){
|
|
|
|
+ //不使用oss直接获取图片路径
|
|
|
|
+ url = res.data.url;
|
|
|
|
+ }
|
|
|
|
+ this.fileList.push({name: file.name,url:url});
|
|
this.emitInput(this.fileList);
|
|
this.emitInput(this.fileList);
|
|
},
|
|
},
|
|
handleExceed(files, fileList) {
|
|
handleExceed(files, fileList) {
|