From e4c4a6f8d278ae88d50cb030e04f8f2dd582ccd2 Mon Sep 17 00:00:00 2001 From: Kuingsmile Date: Tue, 30 Apr 2024 14:31:33 +0800 Subject: [PATCH 1/6] :sparkles: Feature(custom): optimize upload api --- src/main/server/routerManager.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/server/routerManager.ts b/src/main/server/routerManager.ts index 0b0c44a1..bf853883 100644 --- a/src/main/server/routerManager.ts +++ b/src/main/server/routerManager.ts @@ -46,6 +46,7 @@ router.post('/upload', async ({ urlparams?: URLSearchParams }): Promise => { try { + const picbed = urlparams?.get('picbed') const passedKey = urlparams?.get('key') const serverKey = picgo.getConfig(configPaths.settings.serverKey) || '' if (serverKey && passedKey !== serverKey) { @@ -58,17 +59,16 @@ router.post('/upload', async ({ }) return } - const picbed = urlparams?.get('picbed') let currentPicBedType = '' let currentPicBedConfig = {} as IStringKeyMap let currentPicBedConfigId = '' let needRestore = false if (picbed) { - const configName = urlparams?.get('configName') || 'Default' const currentPicBed = picgo.getConfig('picBed') || {} as IStringKeyMap - currentPicBedType = currentPicBed?.current - currentPicBedConfig = currentPicBed?.[currentPicBedType] - currentPicBedConfigId = currentPicBedConfig?._id + currentPicBedType = currentPicBed.current || '' + currentPicBedConfig = currentPicBed[currentPicBedType] || {} as IStringKeyMap + currentPicBedConfigId = currentPicBedConfig._id + const configName = urlparams?.get('configName') || currentPicBed[picbed]?._configName if (picbed === currentPicBedType && configName === currentPicBedConfig._configName) { // do nothing } else { From 8cc07dc7586d2cff104eb65857c7f02ba1b2aecf Mon Sep 17 00:00:00 2001 From: Kuingsmile Date: Tue, 30 Apr 2024 17:28:33 +0800 Subject: [PATCH 2/6] :hammer: Refactor(custom): optimize delete endpoint --- src/main/server/routerManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/server/routerManager.ts b/src/main/server/routerManager.ts index bf853883..29881a24 100644 --- a/src/main/server/routerManager.ts +++ b/src/main/server/routerManager.ts @@ -190,9 +190,9 @@ router.post('/delete', async ({ return } try { + const aesHelper = new AESHelper() const treatList = list.map(item => { if (!item.isEncrypted) return item - const aesHelper = new AESHelper() return JSON.parse(aesHelper.decrypt(item.EncryptedData)) }) const result = await deleteChoosedFiles(treatList) From 9ca0e4b46945bd79dd970a8ebe46bf6384315764 Mon Sep 17 00:00:00 2001 From: Kuingsmile Date: Wed, 8 May 2024 22:59:02 +0800 Subject: [PATCH 3/6] :sparkles: Feature(custom): optimize aws s3 and buildin rename --- package.json | 2 +- src/renderer/manage/utils/common.ts | 90 +++++++++++++++++------------ yarn.lock | 8 +-- 3 files changed, 58 insertions(+), 42 deletions(-) diff --git a/package.json b/package.json index a87ad66e..8f09fceb 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "multer": "^1.4.5-lts.1", "node-ssh-no-cpu-features": "^1.0.1", "nodejs-file-downloader": "^4.12.1", - "piclist": "^1.8.7", + "piclist": "^1.8.8", "pinia": "^2.1.7", "pinia-plugin-persistedstate": "^3.2.0", "proxy-agent": "^5.0.0", diff --git a/src/renderer/manage/utils/common.ts b/src/renderer/manage/utils/common.ts index 06c55438..ad9cf042 100644 --- a/src/renderer/manage/utils/common.ts +++ b/src/renderer/manage/utils/common.ts @@ -46,21 +46,29 @@ export function renameFileNameWithCustomString (oldName: string, customFormat: s '{y}': () => year.slice(2), '{m}': () => renameFormatHelper(date.getMonth() + 1), '{d}': () => renameFormatHelper(date.getDate()), + '{h}': () => renameFormatHelper(date.getHours()), + '{i}': () => renameFormatHelper(date.getMinutes()), + '{s}': () => renameFormatHelper(date.getSeconds()), + '{ms}': () => date.getMilliseconds().toString().padStart(3, '0'), '{md5}': () => getMd5(fileBaseName), '{md5-16}': () => getMd5(fileBaseName).slice(0, 16), - '{str-10}': () => randomStringGenerator(10), - '{str-20}': () => randomStringGenerator(20), '{filename}': () => affixFileName ? path.basename(affixFileName, path.extname(affixFileName)) : path.basename(oldName, path.extname(oldName)), '{uuid}': () => uuidv4().replace(/-/g, ''), - '{timestamp}': () => Math.floor(Date.now() / 1000).toString() + '{timestamp}': () => date.getTime().toString() } - if (customFormat === undefined || !Object.keys(conversionMap).some(item => customFormat.includes(item))) { + if (customFormat === undefined || (!Object.keys(conversionMap).some(item => customFormat.includes(item)) && !customFormat.includes('{str-'))) { return oldName } const ext = path.extname(oldName) - return Object.keys(conversionMap).reduce((acc, cur) => { + let newName = Object.keys(conversionMap).reduce((acc, cur) => { return acc.replace(new RegExp(cur, 'g'), conversionMap[cur]()) }, customFormat) + ext + const strRegex = /{str-(\d+)}/gi + newName = newName.replace(strRegex, (_, group1) => { + const length = parseInt(group1, 10) + return randomStringGenerator(length) + }) + return newName } export function renameFile ({ timestampRename, randomStringRename, customRename, customRenameFormat }: IStringKeyMap, oldName = ''): string { @@ -217,9 +225,21 @@ export const customRenameFormatTable = [ placeholderB: '{d}', descriptionB: '日期(01-31)' }, + { + placeholder: '{h}', + description: '小时(00-23)', + placeholderB: '{i}', + descriptionB: '分钟(00-59)' + }, + { + placeholder: '{s}', + description: '秒(00-59)', + placeholderB: '{ms}', + descriptionB: '毫秒(000-999)' + }, { placeholder: '{timestamp}', - description: '时间戳(秒)', + description: '时间戳(毫秒)', placeholderB: '{uuid}', descriptionB: 'uuid字符串' }, @@ -230,14 +250,10 @@ export const customRenameFormatTable = [ descriptionB: 'md5前16位' }, { - placeholder: '{str-10}', + placeholder: '{str-number}', description: '10位随机字符串', - placeholderB: '{str-20}', - descriptionB: '20位随机字符串' - }, - { - placeholder: '{filename}', - description: '原文件名' + placeholderB: '{filename}', + descriptionB: '原文件名' } ] @@ -245,47 +261,47 @@ export const buildInRenameFormatTable = [ { placeholder: '{Y}', description: '年份,4位数', - placeholderB: '{y}', - descriptionB: '年份,2位数' + placeholderB: '{timestamp}', + descriptionB: '时间戳(毫秒)' }, { - placeholder: '{m}', - description: '月份(01-12)', - placeholderB: '{d}', - descriptionB: '日期(01-31)' + placeholder: '{y}', + description: '年份,2位数', + placeholderB: '{md5}', + descriptionB: 'md5' }, { - placeholder: '{h}', - description: '小时(00-23)', - placeholderB: '{i}', - descriptionB: '分钟(00-59)' + placeholder: '{m}', + description: '月份(01-12)', + placeholderB: '{md5-16}', + descriptionB: 'md5前16位' }, { - placeholder: '{s}', - description: '秒(00-59)', + placeholder: '{d}', + description: '日期(01-31)', placeholderB: '{localFolder:}', descriptionB: '本地文件夹层级' }, { - placeholder: '{timestamp}', - description: '时间戳(秒)', + placeholder: '{h}', + description: '小时(00-23)', placeholderB: '{uuid}', descriptionB: 'uuid字符串' }, { - placeholder: '{md5}', - description: 'md5', - placeholderB: '{md5-16}', - descriptionB: 'md5前16位' + placeholder: '{i}', + description: '分钟(00-59)', + placeholderB: '{filename}', + descriptionB: '原文件名' }, { - placeholder: '{str-10}', - description: '10位随机字符串', - placeholderB: '{str-20}', - descriptionB: '20位随机字符串' + placeholder: '{s}', + description: '秒(00-59)', + placeholderB: '{str-number}', + descriptionB: 'number位随机字符串' }, { - placeholder: '{filename}', - description: '原文件名' + placeholder: '{ms}', + description: '毫秒(000-999)' } ] diff --git a/yarn.lock b/yarn.lock index b897d756..8e5dc0c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12397,10 +12397,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.8.7: - version "1.8.7" - resolved "https://registry.yarnpkg.com/piclist/-/piclist-1.8.7.tgz#aa40af42762b857ac0c45a097421278a301320cf" - integrity sha512-asSc588Fh1aMpIq/guqqHGhZb0wsLn+wZllKbtznDasbh4zNZvQECNDxRGVtmvsSYJlR+V+yyA2Z85AW/aQqyA== +piclist@^1.8.8: + version "1.8.8" + resolved "https://registry.yarnpkg.com/piclist/-/piclist-1.8.8.tgz#a4b3b4bcdd88f48de5469497e140187ea6e46ab7" + integrity sha512-2sucOVbqVNukb0FZ4ne+DG6bzAJIxZJgm1HlOHKk/NOKYvbcXLsHq0whtEsbfwnsFmkF5T9uJtXHwZPE86JoQA== dependencies: "@aws-sdk/client-s3" "3.421.0" "@aws-sdk/lib-storage" "3.421.0" From 01539918a4f2926030fa13cfe5165a7db279c395 Mon Sep 17 00:00:00 2001 From: Kuingsmile Date: Sun, 12 May 2024 20:12:28 +0800 Subject: [PATCH 4/6] :sparkles: Feature(custom): add support for oss-cn-wuhan --- src/main/manage/utils/constants.ts | 1 + src/renderer/manage/utils/common.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/manage/utils/constants.ts b/src/main/manage/utils/constants.ts index 8cc0862a..afaaada6 100644 --- a/src/main/manage/utils/constants.ts +++ b/src/main/manage/utils/constants.ts @@ -3,6 +3,7 @@ const AliyunAreaCodeName : IStringKeyMap = { 'oss-cn-shanghai': '华东2(上海)', 'oss-cn-nanjing': '华东5(南京)', 'oss-cn-fuzhou': '华东6(福州)', + 'oss-cn-wuhan': '华中1(武汉)', 'oss-cn-qingdao': '华北1(青岛)', 'oss-cn-beijing': '华北2(北京)', 'oss-cn-zhangjiakou': '华北3(张家口)', diff --git a/src/renderer/manage/utils/common.ts b/src/renderer/manage/utils/common.ts index ad9cf042..584460be 100644 --- a/src/renderer/manage/utils/common.ts +++ b/src/renderer/manage/utils/common.ts @@ -251,7 +251,7 @@ export const customRenameFormatTable = [ }, { placeholder: '{str-number}', - description: '10位随机字符串', + description: 'number位随机字符串', placeholderB: '{filename}', descriptionB: '原文件名' } From 3d3b80f939553b0aece7a0485b4ea989bdee9319 Mon Sep 17 00:00:00 2001 From: Kuingsmile Date: Mon, 13 May 2024 15:35:55 +0800 Subject: [PATCH 5/6] :pencil: Docs(custom): prepare for v2.8.5 --- currentVersion.md | 19 +++++++++---------- currentVersion_en.md | 18 +++++++++--------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/currentVersion.md b/currentVersion.md index 4274de9a..bbc11daa 100644 --- a/currentVersion.md +++ b/currentVersion.md @@ -1,15 +1,14 @@ - ### ✨ Features -- 管理功能 - - 现在修改自定义域名后会自动强制刷新当前页面 - - 现在第一次进入管理页面时默认获取云端最新文件列表 -- 现在内置s3图床默认允许自签证书 -- 现在高级重命名中的时间戳精确到毫秒 +- 现在`upload`接口只传递`picbed`参数时,使用对应图床的默认配置,而不是`Default`配置 +- 优化了对smms图床的备用域名的处理逻辑 +- 内置aws S3图床现在设置权限时使用下拉选择框,同时`disableBucketPrefixToURL`现在修改为布尔类型 +- 高级重命名现在支持`{str-number}`格式,其中number为任意数字,新增`{ms}`(毫秒)的支持 +- 管理功能中,上传自定义重命名新增对`{h}`(小时),`{i}`(分钟),`{s}`(秒),,同时`{timestamp}`修改为毫秒,新增对`{str-number}`的支持 +- 管理功能中,阿里云图床新增对创建`oss-cn-wuhan(华南1-武汉)`地域存储桶的支持 +- 优化了重命名占位符说明页面的排版 +- Docker版本PicList-core现在修改时区为东八区 ### 🐛 Bug Fixes -- 管理功能 - - 修复了强制https对本地图床没有生效的问题 -- 修复了不填写区域时,minio无法正常删除图片的问题 -- 修复了内置s3图床,配合minio使用时会额外添加桶名的问题 +- 修正了高级重命名中时间戳的说明,由秒修改为毫秒 diff --git a/currentVersion_en.md b/currentVersion_en.md index 4f297a3e..48aa161f 100644 --- a/currentVersion_en.md +++ b/currentVersion_en.md @@ -1,14 +1,14 @@ ### ✨ Features -- Manage - - Now, after modifying the custom domain name, the current page will be automatically forced to refresh - - Now, the cloud-side latest file list is obtained by default when entering the management page for the first time -- Now the built-in s3 image bed defaults to allowing self-signed certificates -- Now the timestamp in advanced renaming is accurate to milliseconds +- Now when the `upload` interface only passes the `picbed` parameter, the default configuration of the corresponding image bed is used instead of the `Default` configuration +- Optimized the processing logic of the backup domain name of the smms image bed +- The built-in aws S3 image bed now uses a drop-down box when setting permissions, and `disableBucketPrefixToURL` is now modified to a boolean type +- Advanced renaming now supports the `{str-number}` format, where number is any number, and adds support for `{ms}` (milliseconds) +- In the management function, the upload custom renaming adds support for `{h}` (hour), `{i}` (minute), `{s}` (second), and `{timestamp}` is modified to milliseconds, and adds support for `{str-number}` +- In the management function, the Alibaba Cloud image bed adds support for creating `oss-cn-wuhan (South China 1-Wuhan)` regional storage buckets +- Optimized the layout of the placeholder description page for renaming +- The Docker version of PicList-core now changes the time zone to East Eight District ### 🐛 Bug Fixes -- Manage - - Fixed the problem that forcing https does not take effect on the local image bed -- Fixed the problem that Minio cannot delete images normally when the region is not filled in -- Fixed the problem that the built-in s3 image bed will add an additional bucket name when used with Minio \ No newline at end of file +- Fixed the description of the timestamp in advanced renaming, changed from seconds to milliseconds From d9e4e30da392cec0a6d791bf09254b9dfb63c667 Mon Sep 17 00:00:00 2001 From: Kuingsmile Date: Mon, 13 May 2024 15:36:22 +0800 Subject: [PATCH 6/6] :tada: Release: v2.8.5 --- CHANGELOG.md | 16 ++++++++++++++++ package.json | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bc45d86..7053f24a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +## :tada: 2.8.5 (2024-05-13) + + +### :sparkles: Features + +* **custom:** add support for oss-cn-wuhan ([0153991](https://github.com/Kuingsmile/piclist/commit/0153991)) +* **custom:** optimize aws s3 and buildin rename ([9ca0e4b](https://github.com/Kuingsmile/piclist/commit/9ca0e4b)) +* **custom:** optimize upload api ([e4c4a6f](https://github.com/Kuingsmile/piclist/commit/e4c4a6f)) + + +### :pencil: Documentation + +* **custom:** prepare for v2.8.5 ([3d3b80f](https://github.com/Kuingsmile/piclist/commit/3d3b80f)) + + + ## :tada: 2.8.4 (2024-04-28) diff --git a/package.json b/package.json index 8f09fceb..a6bae0a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "piclist", - "version": "2.8.4", + "version": "2.8.5", "author": { "name": "Kuingsmile", "email": "pkukuing@gmail.com"