From c4b0235d610f5808ce68901cb51afa79cc8052ab 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: Tue, 23 May 2023 14:52:36 +0800 Subject: [PATCH] :sparkles: Feature: add addvanced rename feature --- package.json | 2 +- public/i18n/en.yml | 3 + public/i18n/zh-CN.yml | 3 + public/i18n/zh-TW.yml | 3 + src/renderer/manage/utils/common.ts | 49 ++++++++++ src/renderer/pages/Gallery.vue | 63 +++++++------ src/renderer/pages/PicGoSetting.vue | 137 +++++++++++++++++++++++++++- src/universal/types/i18n.d.ts | 3 + yarn.lock | 9 +- 9 files changed, 239 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index 9bb58a1..4594b88 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "mime-types": "^2.1.35", "mitt": "^3.0.0", "nodejs-file-downloader": "^4.10.6", - "piclist": "^0.6.6", + "piclist": "^0.6.7", "pinia": "^2.0.32", "pinia-plugin-persistedstate": "^3.1.0", "qiniu": "^7.8.0", diff --git a/public/i18n/en.yml b/public/i18n/en.yml index bddd50c..40b22e1 100644 --- a/public/i18n/en.yml +++ b/public/i18n/en.yml @@ -168,6 +168,9 @@ SETTINGS_ACCEPT_BETA_UPDATE: Accept Beta Update SETTINGS_LAUNCH_ON_BOOT: Launch On Boot SETTINGS_RENAME_BEFORE_UPLOAD: Rename Before Upload SETTINGS_TIMESTAMP_RENAME: Timestamp Rename +SETTINGS_ADVANCED_RENAME: Advanced Rename +SETTINGS_ADVANCED_RENAME_ENABLE: Enable Advanced Rename +SETTINGS_ADVANCED_RENAME_FORMAT: Advanced Rename Format SETTINGS_OPEN_UPLOAD_TIPS: Open Upload Tips SETTINGS_MINI_WINDOW_ON_TOP: Mini Window On Top SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: Auto Copy URL After Upload diff --git a/public/i18n/zh-CN.yml b/public/i18n/zh-CN.yml index 8402f48..3c50ac7 100644 --- a/public/i18n/zh-CN.yml +++ b/public/i18n/zh-CN.yml @@ -170,6 +170,9 @@ SETTINGS_ACCEPT_BETA_UPDATE: 接受Beta版本更新 SETTINGS_LAUNCH_ON_BOOT: 开机自启 SETTINGS_RENAME_BEFORE_UPLOAD: 上传前重命名 SETTINGS_TIMESTAMP_RENAME: 时间戳重命名 +SETTINGS_ADVANCED_RENAME: 高级重命名 +SETTINGS_ADVANCED_RENAME_ENABLE: 开启高级重命名 +SETTINGS_ADVANCED_RENAME_FORMAT: 重命名格式 SETTINGS_OPEN_UPLOAD_TIPS: 开启上传提示 SETTINGS_MINI_WINDOW_ON_TOP: Mini窗口置顶 SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: 上传后自动复制URL diff --git a/public/i18n/zh-TW.yml b/public/i18n/zh-TW.yml index 64a6483..8000323 100644 --- a/public/i18n/zh-TW.yml +++ b/public/i18n/zh-TW.yml @@ -168,6 +168,9 @@ SETTINGS_ACCEPT_BETA_UPDATE: 接受Beta版本更新 SETTINGS_LAUNCH_ON_BOOT: 開機時啟動 SETTINGS_RENAME_BEFORE_UPLOAD: 上傳前重新命名 SETTINGS_TIMESTAMP_RENAME: 以時間戳命名 +SETTINGS_ADVANCED_RENAME: 高級命名 +SETTINGS_ADVANCED_RENAME_ENABLE: 啟用高級命名 +SETTINGS_ADVANCED_RENAME_FORMAT: 高級命名格式 SETTINGS_OPEN_UPLOAD_TIPS: 開啟上傳提示 SETTINGS_MINI_WINDOW_ON_TOP: Mini視窗置頂 SETTINGS_AUTO_COPY_URL_AFTER_UPLOAD: 上傳後自動複製URL diff --git a/src/renderer/manage/utils/common.ts b/src/renderer/manage/utils/common.ts index 5124d52..abcf795 100644 --- a/src/renderer/manage/utils/common.ts +++ b/src/renderer/manage/utils/common.ts @@ -217,3 +217,52 @@ export const customRenameFormatTable = [ description: '原文件名' } ] + +export const buildInRenameFormatTable = [ + { + placeholder: '{Y}', + description: '年份,4位数', + placeholderB: '{y}', + descriptionB: '年份,2位数' + }, + { + placeholder: '{m}', + description: '月份(01-12)', + placeholderB: '{d}', + descriptionB: '日期(01-31)' + }, + { + placeholder: '{h}', + description: '小时(00-23)', + placeholderB: '{i}', + descriptionB: '分钟(00-59)' + }, + { + placeholder: '{s}', + description: '秒(00-59)', + placeholderB: '{localFolder:}', + descriptionB: '本地文件夹层级' + }, + { + placeholder: '{timestamp}', + description: '时间戳(秒)', + placeholderB: '{uuid}', + descriptionB: 'uuid字符串' + }, + { + placeholder: '{md5}', + description: 'md5', + placeholderB: '{md5-16}', + descriptionB: 'md5前16位' + }, + { + placeholder: '{str-10}', + description: '10位随机字符串', + placeholderB: '{str-20}', + descriptionB: '20位随机字符串' + }, + { + placeholder: '{filename}', + description: '原文件名' + } +] diff --git a/src/renderer/pages/Gallery.vue b/src/renderer/pages/Gallery.vue index 87cc2a2..cc6bad7 100644 --- a/src/renderer/pages/Gallery.vue +++ b/src/renderer/pages/Gallery.vue @@ -661,39 +661,48 @@ function remove (item: ImgInfo) { type: 'warning' }).then(async () => { const file = await $$db.getById(item.id!) - await $$db.removeById(item.id!) const picBedsCanbeDeleted = ['smms', 'github', 'imgur', 'tcyun', 'aliyun', 'qiniu', 'upyun', 'aws-s3', 'webdavplist'] if (await getConfig('settings.deleteCloudFile')) { if (item.type !== undefined && picBedsCanbeDeleted.includes(item.type)) { - setTimeout(() => { - ALLApi.delete(item).then((value: boolean) => { - if (value) { - ElNotification({ - title: $T('GALLERY_SYNC_DELETE_NOTICE_TITLE'), - message: `${item.fileName} ${$T('GALLERY_SYNC_DELETE_NOTICE_SUCCEED')}`, - type: 'success' - }) - } else { - ElNotification({ - title: $T('GALLERY_SYNC_DELETE_NOTICE_TITLE'), - message: `${item.fileName} ${$T('GALLERY_SYNC_DELETE_NOTICE_FAILED')}`, - type: 'error' - }) - } + 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' }) - }, 0) + 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' + }) + } } + } 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() } - 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 diff --git a/src/renderer/pages/PicGoSetting.vue b/src/renderer/pages/PicGoSetting.vue index 8c463f9..fa3bea1 100644 --- a/src/renderer/pages/PicGoSetting.vue +++ b/src/renderer/pages/PicGoSetting.vue @@ -319,6 +319,18 @@ @change="handleAutoRename" /> + + + {{ $T('SETTINGS_CLICK_TO_SET') }} + + @@ -721,6 +733,99 @@ + + + {{ $T('SETTINGS_ADVANCED_RENAME_ENABLE') }} + +
+ +
+ + + {{ $T('SETTINGS_ADVANCED_RENAME_FORMAT') }} + + + + + {{ item.description }} + + + {{ item.descriptionB }} + + + + + + +
+ + {{ $T('CANCEL') }} + + + {{ $T('CONFIRM') }} + +
+