Skip to content

Commit

Permalink
✨ Feature(tcyun): add slim section (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
yc910920 authored Aug 23, 2023
1 parent 42494ac commit 30ee4fc
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export const EN: ILocales = {
PICBED_TENCENTCLOUD_ENDPOINT: 'Set Endpoint',
PICBED_TENCENTCLOUD_PATH: 'Set Path',
PICBED_TENCENTCLOUD_OPTIONS: 'Set URL Suffix',
PICBED_TENCENTCLOUD_SLIM: 'Set ImageSlim',
PICBED_TENCENTCLOUD_SLIM_TIP: 'Image extremely intelligent compression, please refer to the [document description](https://cloud.tencent.com/document/product/436/49259)',
PICBED_TENCENTCLOUD_SLIM_CONFIRM: 'OPEN',
PICBED_TENCENTCLOUD_SLIM_CANCEL: 'CLOSE',
PICBED_TENCENTCLOUD_CUSTOMURL: 'Set Custom URL',
PICBED_TENCENTCLOUD_MESSAGE_APPID: 'Ex. 1234567890',
PICBED_TENCENTCLOUD_MESSAGE_AREA: 'Ex. ap-beijing',
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ export const ZH_CN = {
PICBED_TENCENTCLOUD_PATH: '设定存储路径',
PICBED_TENCENTCLOUD_OPTIONS: '设定网址后缀',
PICBED_TENCENTCLOUD_CUSTOMURL: '设定自定义域名',
PICBED_TENCENTCLOUD_SLIM: '极智压缩',
PICBED_TENCENTCLOUD_SLIM_TIP: '图片极智压缩,详情请参考[文档说明](https://cloud.tencent.com/document/product/436/49259)',
PICBED_TENCENTCLOUD_SLIM_CONFIRM: '开启',
PICBED_TENCENTCLOUD_SLIM_CANCEL: '关闭',
PICBED_TENCENTCLOUD_MESSAGE_APPID: '例如:1234567890',
PICBED_TENCENTCLOUD_MESSAGE_AREA: '例如:ap-beijing',
PICBED_TENCENTCLOUD_MESSAGE_ENDPOINT: '例如:cos-internal.accelerate.tencentcos.cn',
Expand Down
4 changes: 4 additions & 0 deletions src/i18n/zh-TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export const ZH_TW: ILocales = {
PICBED_TENCENTCLOUD_ENDPOINT: '設定Endpoint',
PICBED_TENCENTCLOUD_PATH: '設定儲存路徑',
PICBED_TENCENTCLOUD_OPTIONS: '設定網址後綴',
PICBED_TENCENTCLOUD_SLIM: '極智壓縮',
PICBED_TENCENTCLOUD_SLIM_CANCEL: '關閉',
PICBED_TENCENTCLOUD_SLIM_CONFIRM: '開啓',
PICBED_TENCENTCLOUD_SLIM_TIP: '圖片極智壓縮,詳情請參考[文檔說明](https://cloud.tencent.com/document/product/436/49259)',
PICBED_TENCENTCLOUD_CUSTOMURL: '設定自訂網址',
PICBED_TENCENTCLOUD_MESSAGE_APPID: '例如:1234567890',
PICBED_TENCENTCLOUD_MESSAGE_AREA: '例如:ap-beijing',
Expand Down
19 changes: 19 additions & 0 deletions src/plugins/uploader/tcyun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const handle = async (ctx: IPicGo): Promise<IPicGo | boolean> => {
}
}
const optionUrl = tcYunOptions.options || ''
const slim = tcYunOptions.slim || ''
if (useV4 && body.message === 'SUCCESS') {
delete img.base64Image
delete img.buffer
Expand All @@ -154,6 +155,13 @@ const handle = async (ctx: IPicGo): Promise<IPicGo | boolean> => {
} else {
throw new Error(res.body.msg)
}
if (slim) {
if (optionUrl) {
img.imgUrl += '&imageSlim'
} else {
img.imgUrl += '?imageSlim'
}
}
}
}
return ctx
Expand Down Expand Up @@ -259,6 +267,17 @@ const config = (ctx: IPicGo): IPluginConfig[] => {
get alias () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_OPTIONS') },
get message () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_MESSAGE_OPTIONS') },
required: false
},
{
name: 'slim',
type: 'confirm',
default: userConfig.options || '',
get prefix () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_SLIM') },
get alias () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_SLIM') },
required: false,
get confirmText () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_SLIM_CONFIRM') },
get cancelText () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_SLIM_CANCEL') },
get tips () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_SLIM_TIP') },
}
]
return config
Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ export interface ITcyunConfig {
version: 'v5' | 'v4'
/** 针对图片的一些后缀处理参数 PicGo 2.4.0+ PicGo-Core 1.5.0+ */
options: string
/** 是否支持极智压缩 */
slim: boolean
}
/** GitHub 图床配置项 */
export interface IGithubConfig {
Expand Down

0 comments on commit 30ee4fc

Please sign in to comment.