mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-02 11:08:13 -05:00
✨ Feature: add antileechtoken and expiretime for upyun manage
This commit is contained in:
parent
2daae921ff
commit
ea61614ddd
@ -527,6 +527,10 @@ MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_DESC: Acceleration domain name - requir
|
|||||||
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_PLACEHOLDER: 'Please start with http:// or https://'
|
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_PLACEHOLDER: 'Please start with http:// or https://'
|
||||||
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_A: Acceleration domain name cannot be empty
|
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_A: Acceleration domain name cannot be empty
|
||||||
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_B: 'Please start the custom domain name with http:// or https://'
|
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_B: 'Please start the custom domain name with http:// or https://'
|
||||||
|
MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_DESC: Anti-leech key - optional
|
||||||
|
MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_PLACEHOLDER: Please enter the anti-leech key
|
||||||
|
MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_TOOLTIP: If you do not need to use anti-leech, please leave it blank
|
||||||
|
MANAGE_CONSTANT_UPYUN_EXPIRE_TIME_DESC: Expiration time(s) - optional
|
||||||
MANAGE_CONSTANT_UPYUN_PAGING: Whether to enable pagination
|
MANAGE_CONSTANT_UPYUN_PAGING: Whether to enable pagination
|
||||||
MANAGE_CONSTANT_UPYUN_ITEMS_PAGE: Number of items displayed per page
|
MANAGE_CONSTANT_UPYUN_ITEMS_PAGE: Number of items displayed per page
|
||||||
MANAGE_CONSTANT_UPYUN_EXPLAIN: It is necessary to fill in the acceleration domain name of Upyun image bed, otherwise it cannot be used normally.
|
MANAGE_CONSTANT_UPYUN_EXPLAIN: It is necessary to fill in the acceleration domain name of Upyun image bed, otherwise it cannot be used normally.
|
||||||
|
@ -530,6 +530,10 @@ MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_DESC: 加速域名-必需
|
|||||||
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_PLACEHOLDER: '请以http://或https://开头'
|
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_PLACEHOLDER: '请以http://或https://开头'
|
||||||
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_A: 加速域名不能为空
|
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_A: 加速域名不能为空
|
||||||
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_B: '自定义域名请以http://或https://开头'
|
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_B: '自定义域名请以http://或https://开头'
|
||||||
|
MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_DESC: 防盗链密钥-可选
|
||||||
|
MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_PLACEHOLDER: 请填写防盗链密钥
|
||||||
|
MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_TOOLTIP: 如果不填写,默认不启用防盗链
|
||||||
|
MANAGE_CONSTANT_UPYUN_EXPIRE_TIME_DESC: 防盗链过期时间(秒)-可选
|
||||||
MANAGE_CONSTANT_UPYUN_PAGING: 是否开启分页
|
MANAGE_CONSTANT_UPYUN_PAGING: 是否开启分页
|
||||||
MANAGE_CONSTANT_UPYUN_ITEMS_PAGE: 每页显示数量
|
MANAGE_CONSTANT_UPYUN_ITEMS_PAGE: 每页显示数量
|
||||||
MANAGE_CONSTANT_UPYUN_EXPLAIN: 又拍云图床务必填写加速域名,否则无法正常使用
|
MANAGE_CONSTANT_UPYUN_EXPLAIN: 又拍云图床务必填写加速域名,否则无法正常使用
|
||||||
|
@ -527,6 +527,10 @@ MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_DESC: 加速域名-必需
|
|||||||
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_PLACEHOLDER: '請以http://或https://開頭'
|
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_PLACEHOLDER: '請以http://或https://開頭'
|
||||||
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_A: 加速域名不能為空
|
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_A: 加速域名不能為空
|
||||||
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_B: '自定義域名請以http://或https://開頭'
|
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_B: '自定義域名請以http://或https://開頭'
|
||||||
|
MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_DESC: 防盗链密钥-可選
|
||||||
|
MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_PLACEHOLDER: 請填寫防盗链密钥
|
||||||
|
MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_TOOLTIP: 如果不填寫,則不啟用防盗链
|
||||||
|
MANAGE_CONSTANT_UPYUN_EXPIRE_TIME_DESC: 防盗链有效期(秒)-可選
|
||||||
MANAGE_CONSTANT_UPYUN_PAGING: 是否開啟分頁
|
MANAGE_CONSTANT_UPYUN_PAGING: 是否開啟分頁
|
||||||
MANAGE_CONSTANT_UPYUN_ITEMS_PAGE: 每頁顯示數量
|
MANAGE_CONSTANT_UPYUN_ITEMS_PAGE: 每頁顯示數量
|
||||||
MANAGE_CONSTANT_UPYUN_EXPLAIN: 又拍雲圖床必須填寫加速域名,否則無法正常使用
|
MANAGE_CONSTANT_UPYUN_EXPLAIN: 又拍雲圖床必須填寫加速域名,否則無法正常使用
|
||||||
|
@ -42,16 +42,29 @@ class UpyunApi {
|
|||||||
bucket: string
|
bucket: string
|
||||||
operator: string
|
operator: string
|
||||||
password: string
|
password: string
|
||||||
|
antiLeechToken: string
|
||||||
|
expireTime: number
|
||||||
stopMarker = 'g2gCZAAEbmV4dGQAA2VvZg'
|
stopMarker = 'g2gCZAAEbmV4dGQAA2VvZg'
|
||||||
logger: ManageLogger
|
logger: ManageLogger
|
||||||
|
|
||||||
constructor (bucket: string, operator: string, password: string, logger: ManageLogger) {
|
constructor (bucket: string, operator: string, password: string, logger: ManageLogger, antiLeechToken?: string, expireTime?: number) {
|
||||||
this.ser = new Upyun.Service(bucket, operator, password)
|
this.ser = new Upyun.Service(bucket, operator, password)
|
||||||
this.cli = new Upyun.Client(this.ser)
|
this.cli = new Upyun.Client(this.ser)
|
||||||
this.bucket = bucket
|
this.bucket = bucket
|
||||||
this.operator = operator
|
this.operator = operator
|
||||||
this.password = password
|
this.password = password
|
||||||
this.logger = logger
|
this.logger = logger
|
||||||
|
this.antiLeechToken = antiLeechToken || ''
|
||||||
|
this.expireTime = expireTime || 24 * 60 * 60
|
||||||
|
}
|
||||||
|
|
||||||
|
getAntiLeechParam (key: string): string {
|
||||||
|
const uri = `/${encodeURIComponent(key)}`.replace(/%2F/g, '/').replace(/^\/+/g, '/')
|
||||||
|
const now = Math.round(new Date().getTime() / 1000)
|
||||||
|
const expire = this.expireTime ? now + parseInt(this.expireTime.toString(), 10) : now + 1800
|
||||||
|
const sign = md5(`${this.antiLeechToken}&${expire}&${uri}`, 'hex')
|
||||||
|
const upt = `${sign.substring(12, 20)}${expire}`
|
||||||
|
return `_upt=${upt}`
|
||||||
}
|
}
|
||||||
|
|
||||||
formatFolder (item: any, slicedPrefix: string) {
|
formatFolder (item: any, slicedPrefix: string) {
|
||||||
@ -72,6 +85,10 @@ class UpyunApi {
|
|||||||
|
|
||||||
formatFile (item: any, slicedPrefix: string, urlPrefix: string) {
|
formatFile (item: any, slicedPrefix: string, urlPrefix: string) {
|
||||||
const key = `${slicedPrefix}${item.name}`
|
const key = `${slicedPrefix}${item.name}`
|
||||||
|
let url = `${urlPrefix}/${key}`
|
||||||
|
if (this.antiLeechToken) {
|
||||||
|
url = `${url}?${this.getAntiLeechParam(key)}`
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
fileName: item.name,
|
fileName: item.name,
|
||||||
@ -81,7 +98,7 @@ class UpyunApi {
|
|||||||
checked: false,
|
checked: false,
|
||||||
match: false,
|
match: false,
|
||||||
isImage: isImage(item.name),
|
isImage: isImage(item.name),
|
||||||
url: `${urlPrefix}/${key}`,
|
url,
|
||||||
key
|
key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ export class ManageApi extends EventEmitter implements ManageApiType {
|
|||||||
case 'tcyun':
|
case 'tcyun':
|
||||||
return new API.TcyunApi(this.currentPicBedConfig.secretId, this.currentPicBedConfig.secretKey, this.logger)
|
return new API.TcyunApi(this.currentPicBedConfig.secretId, this.currentPicBedConfig.secretKey, this.logger)
|
||||||
case 'upyun':
|
case 'upyun':
|
||||||
return new API.UpyunApi(this.currentPicBedConfig.bucketName, this.currentPicBedConfig.operator, this.currentPicBedConfig.password, this.logger)
|
return new API.UpyunApi(this.currentPicBedConfig.bucketName, this.currentPicBedConfig.operator, this.currentPicBedConfig.password, this.logger, this.currentPicBedConfig.antiLeechToken, this.currentPicBedConfig.expireTime)
|
||||||
case 'webdavplist':
|
case 'webdavplist':
|
||||||
return new API.WebdavplistApi(this.currentPicBedConfig.endpoint, this.currentPicBedConfig.username, this.currentPicBedConfig.password, this.currentPicBedConfig.sslEnabled, this.currentPicBedConfig.proxy, this.logger)
|
return new API.WebdavplistApi(this.currentPicBedConfig.endpoint, this.currentPicBedConfig.username, this.currentPicBedConfig.password, this.currentPicBedConfig.sslEnabled, this.currentPicBedConfig.proxy, this.logger)
|
||||||
default:
|
default:
|
||||||
|
@ -685,6 +685,8 @@ async function transUpToManage (config: IUploaderConfigListItem, picBedName: str
|
|||||||
operator: config.operator,
|
operator: config.operator,
|
||||||
password: config.password,
|
password: config.password,
|
||||||
bucketName: config.bucket,
|
bucketName: config.bucket,
|
||||||
|
antiLeechToken: config.antiLeechToken,
|
||||||
|
expireTime: config.expireTime,
|
||||||
baseDir: '/',
|
baseDir: '/',
|
||||||
customUrl: config.url,
|
customUrl: config.url,
|
||||||
transformedConfig: JSON.stringify({
|
transformedConfig: JSON.stringify({
|
||||||
|
@ -494,6 +494,20 @@ export const supportedPicBedList: IStringKeyMap = {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
antiLeechToken: {
|
||||||
|
required: false,
|
||||||
|
description: $T('MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_DESC'),
|
||||||
|
placeholder: $T('MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_PLACEHOLDER'),
|
||||||
|
type: 'string',
|
||||||
|
default: '',
|
||||||
|
tooltip: $T('MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_TOOLTIP')
|
||||||
|
},
|
||||||
|
expireTime: {
|
||||||
|
required: false,
|
||||||
|
description: $T('MANAGE_CONSTANT_UPYUN_EXPIRE_TIME_DESC'),
|
||||||
|
type: 'number',
|
||||||
|
default: 0
|
||||||
|
},
|
||||||
paging: {
|
paging: {
|
||||||
required: true,
|
required: true,
|
||||||
description: $T('MANAGE_CONSTANT_UPYUN_PAGING'),
|
description: $T('MANAGE_CONSTANT_UPYUN_PAGING'),
|
||||||
@ -511,7 +525,7 @@ export const supportedPicBedList: IStringKeyMap = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
explain: $T('MANAGE_CONSTANT_UPYUN_EXPLAIN'),
|
explain: $T('MANAGE_CONSTANT_UPYUN_EXPLAIN'),
|
||||||
options: ['alias', 'bucketName', 'operator', 'password', 'baseDir', 'customUrl', 'paging', 'itemsPerPage'],
|
options: ['alias', 'bucketName', 'operator', 'password', 'baseDir', 'customUrl', 'paging', 'itemsPerPage', 'antiLeechToken', 'expireTime'],
|
||||||
refLink: 'https://piclist.cn/manage.html#%E5%8F%88%E6%8B%8D%E4%BA%91',
|
refLink: 'https://piclist.cn/manage.html#%E5%8F%88%E6%8B%8D%E4%BA%91',
|
||||||
referenceText: $T('MANAGE_CONSTANT_UPYUN_REFER_TEXT')
|
referenceText: $T('MANAGE_CONSTANT_UPYUN_REFER_TEXT')
|
||||||
},
|
},
|
||||||
|
4
src/universal/types/i18n.d.ts
vendored
4
src/universal/types/i18n.d.ts
vendored
@ -492,6 +492,10 @@ interface ILocales {
|
|||||||
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_PLACEHOLDER: string
|
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_PLACEHOLDER: string
|
||||||
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_A: string
|
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_A: string
|
||||||
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_B: string
|
MANAGE_CONSTANT_UPYUN_IS_AUTO_CUSTOM_URL_RULE_MESSAGE_B: string
|
||||||
|
MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_DESC: string
|
||||||
|
MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_PLACEHOLDER: string
|
||||||
|
MANAGE_CONSTANT_UPYUN_ANTI_LEECH_TOKEN_TOOLTIP: string
|
||||||
|
MANAGE_CONSTANT_UPYUN_EXPIRE_TIME_DESC: string
|
||||||
MANAGE_CONSTANT_UPYUN_PAGING: string
|
MANAGE_CONSTANT_UPYUN_PAGING: string
|
||||||
MANAGE_CONSTANT_UPYUN_ITEMS_PAGE: string
|
MANAGE_CONSTANT_UPYUN_ITEMS_PAGE: string
|
||||||
MANAGE_CONSTANT_UPYUN_EXPLAIN: string
|
MANAGE_CONSTANT_UPYUN_EXPLAIN: string
|
||||||
|
Loading…
Reference in New Issue
Block a user