From dd6bfe68648a2d67d6f9e0dc6ec144b1410ca091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E8=90=8C=E5=93=92=E8=B5=AB=E8=90=9D?= Date: Wed, 6 Sep 2023 01:16:53 -0700 Subject: [PATCH] :sparkles: Feature: add telegra.ph picbed support --- package.json | 2 +- src/renderer/pages/Gallery.vue | 86 ++++++++++++++-------------------- yarn.lock | 8 ++-- 3 files changed, 41 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index d282149..e23f16c 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "mitt": "^3.0.1", "node-ssh-no-cpu-features": "^1.0.1", "nodejs-file-downloader": "^4.12.1", - "piclist": "^1.0.1", + "piclist": "^1.0.2", "pinia": "^2.1.6", "pinia-plugin-persistedstate": "^3.2.0", "qiniu": "^7.9.0", diff --git a/src/renderer/pages/Gallery.vue b/src/renderer/pages/Gallery.vue index a7a9c12..8ab5503 100644 --- a/src/renderer/pages/Gallery.vue +++ b/src/renderer/pages/Gallery.vue @@ -682,59 +682,45 @@ async function copy (item: ImgInfo) { } function remove (item: ImgInfo) { - if (item.id) { - $confirm($T('TIPS_REMOVE_LINK'), $T('TIPS_NOTICE'), { - confirmButtonText: $T('CONFIRM'), - cancelButtonText: $T('CANCEL'), - type: 'warning' - }).then(async () => { - const file = await $$db.getById(item.id!) - if (await getConfig('settings.deleteCloudFile')) { - if (item.type !== undefined && picBedsCanbeDeleted.includes(item.type)) { - const result = await ALLApi.delete(item) - if (result) { - ElNotification({ - title: $T('GALLERY_SYNC_DELETE_NOTICE_TITLE'), - message: `${item.fileName} ${$T('GALLERY_SYNC_DELETE_NOTICE_SUCCEED')}`, - type: 'success' - }) - await $$db.removeById(item.id!) - sendToMain('removeFiles', [file]) - const obj = { - title: $T('OPERATION_SUCCEED'), - body: '' - } - const myNotification = new Notification(obj.title, obj) - myNotification.onclick = () => { - return true - } - updateGallery() - } else { - ElNotification({ - title: $T('GALLERY_SYNC_DELETE_NOTICE_TITLE'), - message: `${item.fileName} ${$T('GALLERY_SYNC_DELETE_NOTICE_FAILED')}`, - type: 'error' - }) - } - } + if (!item.id) return + $confirm($T('TIPS_REMOVE_LINK'), $T('TIPS_NOTICE'), { + confirmButtonText: $T('CONFIRM'), + cancelButtonText: $T('CANCEL'), + type: 'warning' + }).then(async () => { + const file = await $$db.getById(item.id!) + if (await getConfig('settings.deleteCloudFile') && picBedsCanbeDeleted.includes(item?.type || 'placeholder')) { + const result = await ALLApi.delete(item) + if (result) { + ElNotification({ + title: $T('GALLERY_SYNC_DELETE_NOTICE_TITLE'), + message: `${item.fileName} ${$T('GALLERY_SYNC_DELETE_NOTICE_SUCCEED')}`, + type: 'success' + }) } else { - await $$db.removeById(item.id!) - sendToMain('removeFiles', [file]) - const obj = { - title: $T('OPERATION_SUCCEED'), - body: '' - } - const myNotification = new Notification(obj.title, obj) - myNotification.onclick = () => { - return true - } - updateGallery() + ElNotification({ + title: $T('GALLERY_SYNC_DELETE_NOTICE_TITLE'), + message: `${item.fileName} ${$T('GALLERY_SYNC_DELETE_NOTICE_FAILED')}`, + type: 'error' + }) + return true } - }).catch((e) => { - console.log(e) + } + await $$db.removeById(item.id!) + sendToMain('removeFiles', [file]) + const obj = { + title: $T('OPERATION_SUCCEED'), + body: '' + } + const myNotification = new Notification(obj.title, obj) + myNotification.onclick = () => { return true - }) - } + } + updateGallery() + }).catch((e) => { + console.log(e) + return true + }) } function handleDeleteCloudFile (val: ICheckBoxValueType) { diff --git a/yarn.lock b/yarn.lock index f2daba6..3ef3ad0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12532,10 +12532,10 @@ performance-now@^2.1.0: resolved "https://registry.npmmirror.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow== -piclist@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/piclist/-/piclist-1.0.1.tgz#6d15ec44393de38b32ba34d041511324ec7dda55" - integrity sha512-c68ijE5Gj3E29KEc1B6F75pluldHLJvkvYmoWhNpYg1hOXGTlxepZCZm8Wp/a9NVjT8jh3zfX1fmpbFGjpOOug== +piclist@^1.0.2: + version "1.0.2" + resolved "https://registry.npmjs.org/piclist/-/piclist-1.0.2.tgz#7a064ef88cf364568aef1e36ea6d9582ebc6119f" + integrity sha512-AUuD7n72ZI9eui1q+QVCdsM7nCYiP3c2bJajOtxYT4UuppRVPoIekM+UBoeTMgSTuzT9yxXAhQH0JXZ27Iy+qg== dependencies: "@picgo/i18n" "^1.0.0" "@picgo/store" "^2.0.4"