Skip to content

Commit 30ee4fc

Browse files
authored
✨ Feature(tcyun): add slim section (#156)
1 parent 42494ac commit 30ee4fc

File tree

5 files changed

+33
-0
lines changed

5 files changed

+33
-0
lines changed

src/i18n/en.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export const EN: ILocales = {
4040
PICBED_TENCENTCLOUD_ENDPOINT: 'Set Endpoint',
4141
PICBED_TENCENTCLOUD_PATH: 'Set Path',
4242
PICBED_TENCENTCLOUD_OPTIONS: 'Set URL Suffix',
43+
PICBED_TENCENTCLOUD_SLIM: 'Set ImageSlim',
44+
PICBED_TENCENTCLOUD_SLIM_TIP: 'Image extremely intelligent compression, please refer to the [document description](https://cloud.tencent.com/document/product/436/49259)',
45+
PICBED_TENCENTCLOUD_SLIM_CONFIRM: 'OPEN',
46+
PICBED_TENCENTCLOUD_SLIM_CANCEL: 'CLOSE',
4347
PICBED_TENCENTCLOUD_CUSTOMURL: 'Set Custom URL',
4448
PICBED_TENCENTCLOUD_MESSAGE_APPID: 'Ex. 1234567890',
4549
PICBED_TENCENTCLOUD_MESSAGE_AREA: 'Ex. ap-beijing',

src/i18n/zh-CN.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ export const ZH_CN = {
3939
PICBED_TENCENTCLOUD_PATH: '设定存储路径',
4040
PICBED_TENCENTCLOUD_OPTIONS: '设定网址后缀',
4141
PICBED_TENCENTCLOUD_CUSTOMURL: '设定自定义域名',
42+
PICBED_TENCENTCLOUD_SLIM: '极智压缩',
43+
PICBED_TENCENTCLOUD_SLIM_TIP: '图片极智压缩,详情请参考[文档说明](https://cloud.tencent.com/document/product/436/49259)',
44+
PICBED_TENCENTCLOUD_SLIM_CONFIRM: '开启',
45+
PICBED_TENCENTCLOUD_SLIM_CANCEL: '关闭',
4246
PICBED_TENCENTCLOUD_MESSAGE_APPID: '例如:1234567890',
4347
PICBED_TENCENTCLOUD_MESSAGE_AREA: '例如:ap-beijing',
4448
PICBED_TENCENTCLOUD_MESSAGE_ENDPOINT: '例如:cos-internal.accelerate.tencentcos.cn',

src/i18n/zh-TW.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export const ZH_TW: ILocales = {
4040
PICBED_TENCENTCLOUD_ENDPOINT: '設定Endpoint',
4141
PICBED_TENCENTCLOUD_PATH: '設定儲存路徑',
4242
PICBED_TENCENTCLOUD_OPTIONS: '設定網址後綴',
43+
PICBED_TENCENTCLOUD_SLIM: '極智壓縮',
44+
PICBED_TENCENTCLOUD_SLIM_CANCEL: '關閉',
45+
PICBED_TENCENTCLOUD_SLIM_CONFIRM: '開啓',
46+
PICBED_TENCENTCLOUD_SLIM_TIP: '圖片極智壓縮,詳情請參考[文檔說明](https://cloud.tencent.com/document/product/436/49259)',
4347
PICBED_TENCENTCLOUD_CUSTOMURL: '設定自訂網址',
4448
PICBED_TENCENTCLOUD_MESSAGE_APPID: '例如:1234567890',
4549
PICBED_TENCENTCLOUD_MESSAGE_AREA: '例如:ap-beijing',

src/plugins/uploader/tcyun.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ const handle = async (ctx: IPicGo): Promise<IPicGo | boolean> => {
134134
}
135135
}
136136
const optionUrl = tcYunOptions.options || ''
137+
const slim = tcYunOptions.slim || ''
137138
if (useV4 && body.message === 'SUCCESS') {
138139
delete img.base64Image
139140
delete img.buffer
@@ -154,6 +155,13 @@ const handle = async (ctx: IPicGo): Promise<IPicGo | boolean> => {
154155
} else {
155156
throw new Error(res.body.msg)
156157
}
158+
if (slim) {
159+
if (optionUrl) {
160+
img.imgUrl += '&imageSlim'
161+
} else {
162+
img.imgUrl += '?imageSlim'
163+
}
164+
}
157165
}
158166
}
159167
return ctx
@@ -259,6 +267,17 @@ const config = (ctx: IPicGo): IPluginConfig[] => {
259267
get alias () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_OPTIONS') },
260268
get message () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_MESSAGE_OPTIONS') },
261269
required: false
270+
},
271+
{
272+
name: 'slim',
273+
type: 'confirm',
274+
default: userConfig.options || '',
275+
get prefix () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_SLIM') },
276+
get alias () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_SLIM') },
277+
required: false,
278+
get confirmText () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_SLIM_CONFIRM') },
279+
get cancelText () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_SLIM_CANCEL') },
280+
get tips () { return ctx.i18n.translate<ILocalesKey>('PICBED_TENCENTCLOUD_SLIM_TIP') },
262281
}
263282
]
264283
return config

src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ export interface ITcyunConfig {
331331
version: 'v5' | 'v4'
332332
/** 针对图片的一些后缀处理参数 PicGo 2.4.0+ PicGo-Core 1.5.0+ */
333333
options: string
334+
/** 是否支持极智压缩 */
335+
slim: boolean
334336
}
335337
/** GitHub 图床配置项 */
336338
export interface IGithubConfig {

0 commit comments

Comments
 (0)