From 1fccdcc8e5c67e04625dc7d1e4e9e99bacdfe765 Mon Sep 17 00:00:00 2001 From: PiEgg Date: Tue, 8 Mar 2022 21:44:03 +0800 Subject: [PATCH] :sparkles: Feature: add options for tencent cos ISSUES CLOSED: #117 --- src/plugins/uploader/tcyun.ts | 13 ++++++++++--- src/types/index.ts | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/plugins/uploader/tcyun.ts b/src/plugins/uploader/tcyun.ts index 42dff87..619de2a 100644 --- a/src/plugins/uploader/tcyun.ts +++ b/src/plugins/uploader/tcyun.ts @@ -123,21 +123,22 @@ const handle = async (ctx: IPicGo): Promise => { if (body.statusCode === 400) { throw new Error(body.msg || body.message) } + const optionUrl = tcYunOptions.options || '' if (useV4 && body.message === 'SUCCESS') { delete img.base64Image delete img.buffer if (customUrl) { img.imgUrl = `${customUrl}/${path}${img.fileName}` } else { - img.imgUrl = body.data.source_url + img.imgUrl = `${body.data.source_url as string}${optionUrl}` } } else if (!useV4 && body && body.statusCode === 200) { delete img.base64Image delete img.buffer if (customUrl) { - img.imgUrl = `${customUrl}/${path}${img.fileName}` + img.imgUrl = `${customUrl}/${path}${img.fileName}${optionUrl}` } else { - img.imgUrl = `https://${tcYunOptions.bucket}.cos.${tcYunOptions.area}.myqcloud.com/${path}${img.fileName}` + img.imgUrl = `https://${tcYunOptions.bucket}.cos.${tcYunOptions.area}.myqcloud.com/${path}${img.fileName}${optionUrl}` } } else { throw new Error(res.body.msg) @@ -221,6 +222,12 @@ const config = (ctx: IPicGo): IPluginConfig[] => { choices: ['v4', 'v5'], default: 'v5', required: false + }, + { + name: 'options', + type: 'input', + default: userConfig.options || '', + required: false } ] return config diff --git a/src/types/index.ts b/src/types/index.ts index c0c6b2d..a348882 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -241,6 +241,8 @@ export interface ITcyunConfig { customUrl: string /** COS 版本,v4 或者 v5 */ version: 'v5' | 'v4' + /** 针对图片的一些后缀处理参数 PicGo 2.4.0+ PicGo-Core 1.5.0+ */ + options: string } /** GitHub 图床配置项 */ export interface IGithubConfig {