Feature(custom): optimize result notification for multi-upload

ISSUES CLOSED: #404
This commit is contained in:
Kuingsmile
2025-11-13 21:57:37 +08:00
parent 0e757406ad
commit 9ff9aeff1e
5 changed files with 24 additions and 9 deletions

View File

@@ -118,7 +118,8 @@ export const uploadChoosedFiles = async (
const pasteStyle = db.get(configPaths.settings.pasteStyle) || IPasteStyle.MARKDOWN
const deleteLocalFile = db.get(configPaths.settings.deleteLocalFile) || false
const pasteText: string[] = []
for (let i = 0; i < imgs.length; i++) {
const imgLength = imgs.length
for (let i = 0; i < imgLength; i++) {
if (deleteLocalFile) {
fs.remove(rawInput[i])
.then(() => {
@@ -140,14 +141,24 @@ export const uploadChoosedFiles = async (
? true
: !!db.get(configPaths.settings.uploadResultNotification)
if (isShowResultNotification) {
const notification = new Notification({
title: $t('UPLOAD_SUCCEED'),
body: shortUrl || imgs[i].imgUrl!
// icon: files[i].path
})
setTimeout(() => {
notification.show()
}, i * 100)
if (imgLength <= 3) {
const notification = new Notification({
title: $t('UPLOAD_SUCCEED'),
body: shortUrl || imgs[i].imgUrl!
// icon: files[i].path
})
setTimeout(() => {
notification.show()
}, i * 100)
} else if (i === imgLength - 1) {
const notification = new Notification({
title: $t('MULTI_UPLOAD_SUCCEED', { n: imgLength }),
body: ''
})
setTimeout(() => {
notification.show()
}, i * 100)
}
}
const inserted = await GalleryDB.getInstance().insert(imgs[i])
result.push({

View File

@@ -7,6 +7,7 @@ export interface ILocales {
CHOOSE_DEFAULT_PICBED: string
RELOAD_APP: string
UPLOAD_SUCCEED: string
MULTI_UPLOAD_SUCCEED: string
UPLOAD_FAILED: string
UPLOAD_PROGRESS: string
UPLOADING: string