Skip to content

Commit 56bd2c8

Browse files
committed
feat(upload-imgs): 增加修改和删除时的内存释放控制
1 parent cf09277 commit 56bd2c8

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/components/base/upload-imgs/index.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ export default {
399399
// 初始化 Draggable
400400
},
401401
methods: {
402-
getValue() {
403-
402+
async getValue() {
403+
// 获取需要上传
404404
},
405405
/**
406406
* 删除某项
@@ -409,13 +409,16 @@ export default {
409409
const { itemList, isStable } = this
410410
// 根据id找到对应项
411411
const index = itemList.findIndex(item => (item.id === id))
412+
const blobUrl = itemList[index].display
412413
if (isStable) {
413414
// 固定数量图片, 删除后留下空项
414415
itemList[index] = createItem()
415416
this.itemList = [...itemList]
416417
} else {
417418
itemList.splice(index, 1)
418419
}
420+
// 释放内存
421+
window.URL.revokeObjectURL(blobUrl)
419422
},
420423
/**
421424
* 预览图像, 后续预览组件制作后替换
@@ -565,6 +568,8 @@ export default {
565568
const { max } = this
566569
// 找到特定图像位置
567570
const index = this.itemList.findIndex(item => (item.id === currentId))
571+
// 释放内存
572+
window.URL.revokeObjectURL(this.itemList[index].display)
568573
// 替换图片
569574
this.itemList[index] = createItem(imgInfoList[0], this.itemList[index])
570575
// 追加图片

0 commit comments

Comments
 (0)