🐛 Fix: fix batch delete bug of gallery page

ISSUES CLOSED: #54
This commit is contained in:
萌萌哒赫萝 2023-05-23 10:02:23 +08:00
parent 5ccb899264
commit 86505c19e2

View File

@ -762,7 +762,7 @@ function multiRemove () {
const files: IResult<ImgInfo>[] = [] const files: IResult<ImgInfo>[] = []
const imageIDList = Object.keys(choosedList) const imageIDList = Object.keys(choosedList)
const isDeleteCloudFile = await getConfig('settings.deleteCloudFile') const isDeleteCloudFile = await getConfig('settings.deleteCloudFile')
const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun'] const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3', 'webdavplist']
if (isDeleteCloudFile) { if (isDeleteCloudFile) {
for (let i = 0; i < imageIDList.length; i++) { for (let i = 0; i < imageIDList.length; i++) {
const key = imageIDList[i] const key = imageIDList[i]
@ -770,15 +770,16 @@ function multiRemove () {
const file = await $$db.getById<ImgInfo>(key) const file = await $$db.getById<ImgInfo>(key)
if (file) { if (file) {
if (file.type !== undefined && picBedsCanbeDeleted.includes(file.type)) { if (file.type !== undefined && picBedsCanbeDeleted.includes(file.type)) {
setTimeout(() => { const result = await ALLApi.delete(file)
ALLApi.delete(file).then((value: boolean) => { if (result) {
if (value) {
ElNotification({ ElNotification({
title: $T('GALLERY_SYNC_DELETE'), title: $T('GALLERY_SYNC_DELETE'),
message: `${file.fileName} ${$T('GALLERY_SYNC_DELETE_NOTICE_SUCCEED')}`, message: `${file.fileName} ${$T('GALLERY_SYNC_DELETE_NOTICE_SUCCEED')}`,
type: 'success', type: 'success',
duration: multiRemoveNumber > 5 ? 1000 : 2000 duration: multiRemoveNumber > 5 ? 1000 : 2000
}) })
files.push(file)
await $$db.removeById(key)
} else { } else {
ElNotification({ ElNotification({
title: $T('GALLERY_SYNC_DELETE'), title: $T('GALLERY_SYNC_DELETE'),
@ -787,11 +788,7 @@ function multiRemove () {
duration: multiRemoveNumber > 5 ? 1000 : 2000 duration: multiRemoveNumber > 5 ? 1000 : 2000
}) })
} }
})
}, 0)
} }
files.push(file)
await $$db.removeById(key)
} }
} }
} }