mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-23 06:38:13 -05:00
✨ Feature(custom): support build-in lsky sync delete
This commit is contained in:
parent
bbbfbda3e2
commit
4c032604c7
@ -13,6 +13,7 @@ import DogeCloudApi from './dogecloud'
|
|||||||
import HuaweicloudApi from './huaweiyun'
|
import HuaweicloudApi from './huaweiyun'
|
||||||
import AlistApi from './alist'
|
import AlistApi from './alist'
|
||||||
import PiclistApi from './piclist'
|
import PiclistApi from './piclist'
|
||||||
|
import LskyplistApi from './lskyplist'
|
||||||
|
|
||||||
const apiMap: IStringKeyMap = {
|
const apiMap: IStringKeyMap = {
|
||||||
aliyun: AliyunApi,
|
aliyun: AliyunApi,
|
||||||
@ -29,7 +30,8 @@ const apiMap: IStringKeyMap = {
|
|||||||
dogecloud: DogeCloudApi,
|
dogecloud: DogeCloudApi,
|
||||||
'huaweicloud-uploader': HuaweicloudApi,
|
'huaweicloud-uploader': HuaweicloudApi,
|
||||||
alist: AlistApi,
|
alist: AlistApi,
|
||||||
piclist: PiclistApi
|
piclist: PiclistApi,
|
||||||
|
lskyplist: LskyplistApi
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class ALLApi {
|
export default class ALLApi {
|
||||||
|
39
src/renderer/apis/lskyplist.ts
Normal file
39
src/renderer/apis/lskyplist.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import axios, { AxiosResponse } from 'axios'
|
||||||
|
import https from 'https'
|
||||||
|
|
||||||
|
export default class LskyplistApi {
|
||||||
|
static async delete (configMap: IStringKeyMap): Promise<boolean> {
|
||||||
|
const { hash, config } = configMap
|
||||||
|
if (!hash || !config || !config.token) {
|
||||||
|
console.error('LskyplistApi.delete: invalid params')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const { host, token, version } = config
|
||||||
|
if (version !== 'V2') {
|
||||||
|
console.error('LskyplistApi.delete: invalid version')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const v2Headers = {
|
||||||
|
Accept: 'application/json',
|
||||||
|
Authorization: token || undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestAgent = new https.Agent({
|
||||||
|
rejectUnauthorized: false
|
||||||
|
})
|
||||||
|
try {
|
||||||
|
const response: AxiosResponse = await axios.delete(
|
||||||
|
`${host}/api/v1/images/${hash}`, {
|
||||||
|
headers: v2Headers,
|
||||||
|
timeout: 30000,
|
||||||
|
httpsAgent: requestAgent
|
||||||
|
})
|
||||||
|
return response.status === 200 && response.data.status === true
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -21,5 +21,6 @@ export const picBedsCanbeDeleted = [
|
|||||||
'dogecloud',
|
'dogecloud',
|
||||||
'huaweicloud-uploader',
|
'huaweicloud-uploader',
|
||||||
'alist',
|
'alist',
|
||||||
'piclist'
|
'piclist',
|
||||||
|
'lskyplist'
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user