修复
This commit is contained in:
@@ -130,10 +130,12 @@ export default {
|
||||
// 然后将数组转为对象数组
|
||||
this.fileList = list.map(item => {
|
||||
if (typeof item === "string") {
|
||||
if (item.indexOf(this.baseUrl) === -1 && !isExternal(item)) {
|
||||
item = { name: this.baseUrl + item, url: this.baseUrl + item }
|
||||
// 如果不是完整URL且不包含baseUrl,则添加baseUrl前缀用于显示
|
||||
if (!isExternal(item) && item.indexOf(this.baseUrl) === -1) {
|
||||
const displayUrl = this.baseUrl + (item.startsWith('/') ? item : '/' + item);
|
||||
item = { name: displayUrl, url: displayUrl }
|
||||
} else {
|
||||
item = { name: item, url: item }
|
||||
item = { name: item, url: item }
|
||||
}
|
||||
}
|
||||
return item
|
||||
@@ -196,13 +198,14 @@ export default {
|
||||
// 上传成功回调
|
||||
handleUploadSuccess(res, file) {
|
||||
if (res.code === 200) {
|
||||
// 根据新的接口返回格式,data字段包含图片路径
|
||||
// 直接使用接口返回的路径,不做任何修改
|
||||
let imagePath = res.data || res.fileName;
|
||||
// 如果路径不是以http开头,则拼接域名前缀
|
||||
// 为了显示需要,临时添加baseUrl前缀
|
||||
let displayUrl = imagePath;
|
||||
if (imagePath && !imagePath.startsWith('http://') && !imagePath.startsWith('https://')) {
|
||||
imagePath = this.baseUrl + imagePath;
|
||||
displayUrl = this.baseUrl + imagePath;
|
||||
}
|
||||
this.uploadList.push({ name: imagePath, url: imagePath })
|
||||
this.uploadList.push({ name: displayUrl, url: displayUrl })
|
||||
this.uploadedSuccessfully()
|
||||
} else {
|
||||
this.number--
|
||||
|
||||
Reference in New Issue
Block a user