diff --git a/resources/i18n/en.yml b/resources/i18n/en.yml index 1a4bf900..743df9fc 100644 --- a/resources/i18n/en.yml +++ b/resources/i18n/en.yml @@ -6,6 +6,7 @@ HIDE_MINI_WINDOW: Hide Mini Window CHOOSE_DEFAULT_PICBED: Choose Default Picbed RELOAD_APP: Reload App UPLOAD_SUCCEED: Upload Succeed +MULTI_UPLOAD_SUCCEED: ${n} Images Uploaded Succeed UPLOAD_FAILED: Upload Failed UPLOAD_PROGRESS: Upload Progress UPLOADING: Uploading diff --git a/resources/i18n/zh-CN.yml b/resources/i18n/zh-CN.yml index 954a8636..4753b1a1 100644 --- a/resources/i18n/zh-CN.yml +++ b/resources/i18n/zh-CN.yml @@ -6,6 +6,7 @@ HIDE_MINI_WINDOW: 隐藏mini窗口 CHOOSE_DEFAULT_PICBED: 选择默认图床 RELOAD_APP: 重启应用 UPLOAD_SUCCEED: 上传成功 +MULTI_UPLOAD_SUCCEED: ${n} 张图片上传成功 UPLOAD_FAILED: 上传失败 UPLOAD_PROGRESS: 上传进度 UPLOADING: 正在上传 diff --git a/resources/i18n/zh-TW.yml b/resources/i18n/zh-TW.yml index 354805d3..d2143eb9 100644 --- a/resources/i18n/zh-TW.yml +++ b/resources/i18n/zh-TW.yml @@ -6,6 +6,7 @@ HIDE_MINI_WINDOW: 隱藏mini視窗 CHOOSE_DEFAULT_PICBED: 選擇預設圖床 RELOAD_APP: 重啟程式 UPLOAD_SUCCEED: 上傳成功 +MULTI_UPLOAD_SUCCEED: ${n} 張圖片上傳成功 UPLOAD_FAILED: 上傳失敗 UPLOAD_PROGRESS: 上傳進度 UPLOADING: 正在上傳 diff --git a/src/main/apis/app/uploader/apis.ts b/src/main/apis/app/uploader/apis.ts index 72f36ff9..34cd74a2 100644 --- a/src/main/apis/app/uploader/apis.ts +++ b/src/main/apis/app/uploader/apis.ts @@ -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({ diff --git a/src/universal/types/i18n.ts b/src/universal/types/i18n.ts index c9338089..5f4ac8d4 100644 --- a/src/universal/types/i18n.ts +++ b/src/universal/types/i18n.ts @@ -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