recycleBin.ts
1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { service as http } from "@/utils/request";
import { transformFileList } from "./files";
// 获取回收站列表
export const listTrash = () => {
return http.get("/files/trash");
};
// 清空回收站
export const emptyTrash = () => {
return http.delete("/files/trash");
};
// 批量还原
export const restoreBatch = (ids: (string | number)[]) => {
return http.post("/files/restore-batch", { ids });
};
// 回收站批量删除(永久删除)
export const trashDeleteBatch = (ids: (string | number)[]) => {
return http.delete("/files/trash-delete-batch", { data: { ids } });
};
export const recycleBinApi = {
async getList(_params: any = {}) {
return await listTrash().then((res: any) => {
const rawItems = res.data || [];
const transformedItems = transformFileList(rawItems);
return {
code: 200,
...res,
data: {
items: transformedItems,
total: transformedItems.length,
},
};
});
},
async restoreItems(payload: {
ids: (string | number)[];
conflictStrategy?: string;
}) {
return restoreBatch(payload.ids).then((res: any) => ({
code: 200,
...res,
data: {
successCount: payload.ids.length,
failCount: 0,
failedItems: [],
},
}));
},
async deleteItems(ids: (string | number)[]) {
return trashDeleteBatch(ids).then((res: any) => ({
code: 200,
...res,
}));
},
async clearAll() {
return await emptyTrash().then((res: any) => ({
code: 200,
...res,
}));
},
async getFolderContent(_folderId: string | number) {
// 实现获取文件夹内容的逻辑
return Promise.resolve({ code: 200, data: [] });
},
async getStatistics() {
// 实现获取统计信息的逻辑
},
};