Skip to content

Commit 16bc8ec

Browse files
committed
✨ Feature: add cloud delete support for alist v3 plugin
1 parent 837027e commit 16bc8ec

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

src/renderer/apis/alist.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import axios from 'axios'
2+
import path from 'path'
3+
4+
export default class AlistApi {
5+
static async delete (configMap: IStringKeyMap): Promise<boolean> {
6+
const { fileName, config } = configMap
7+
try {
8+
const { version, url, uploadPath, token } = config
9+
if (String(version) === '2') return true
10+
const result = await axios.request({
11+
method: 'post',
12+
url: `${url}/api/fs/remove`,
13+
headers: {
14+
'Content-Type': 'application/json',
15+
Authorization: token
16+
},
17+
data: {
18+
dir: path.join('/', uploadPath, path.dirname(fileName)),
19+
names: [path.basename(fileName)]
20+
}
21+
})
22+
return result.data.code === 200
23+
} catch (error) {
24+
console.error(error)
25+
return false
26+
}
27+
}
28+
}

src/renderer/apis/allApi.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import UpyunApi from './upyun'
1111
import WebdavApi from './webdav'
1212
import DogeCloudApi from './dogecloud'
1313
import HuaweicloudApi from './huaweiyun'
14+
import AlistApi from './alist'
1415

1516
const apiMap: IStringKeyMap = {
1617
aliyun: AliyunApi,
@@ -25,7 +26,8 @@ const apiMap: IStringKeyMap = {
2526
upyun: UpyunApi,
2627
webdavplist: WebdavApi,
2728
dogecloud: DogeCloudApi,
28-
'huaweicloud-uploader': HuaweicloudApi
29+
'huaweicloud-uploader': HuaweicloudApi,
30+
alist: AlistApi
2931
}
3032

3133
export default class ALLApi {

src/universal/utils/static.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export const RELEASE_URL_BACKUP = 'https://release.piclist.cn'
66
export const STABLE_RELEASE_URL = 'https://github.com/Kuingsmile/PicList/releases/latest'
77
export const C1 = Buffer.from(C1N, 'base64').toString()
88

9-
export const picBedsCanbeDeleted = ['aliyun', 'aws-s3', 'github', 'imgur', 'local', 'sftpplist', 'smms', 'qiniu', 'tcyun', 'upyun', 'webdavplist', 'dogecloud', 'huaweicloud-uploader']
9+
export const picBedsCanbeDeleted = ['aliyun', 'aws-s3', 'github', 'imgur', 'local', 'sftpplist', 'smms', 'qiniu', 'tcyun', 'upyun', 'webdavplist', 'dogecloud', 'huaweicloud-uploader', 'alist']

0 commit comments

Comments
 (0)