基础优化
This commit is contained in:
1 parent
b606190e0c
commit
6394ac16a2
14 files changed
+457
-177
No files matched your search
@@ -137,9 +137,19 @@ function patch(url, body, options = {}) {
|
||||
|
||||
/**
|
||||
* DELETE 请求
|
||||
* 支持带 body 的 DELETE 请求(用于批量删除等操作)
|
||||
*/
|
||||
function del(url, options = {}) {
|
||||
return request(url, { method: 'DELETE', ...options });
|
||||
function del(url, body, options = {}) {
|
||||
// 如果 body 是对象(非 options),则作为请求体发送
|
||||
if (body && typeof body === 'object' && !body.method) {
|
||||
return request(url, {
|
||||
method: 'DELETE',
|
||||
body: JSON.stringify(body),
|
||||
...options
|
||||
});
|
||||
}
|
||||
// 否则,body 实际上是 options
|
||||
return request(url, { method: 'DELETE', ...body });
|
||||
}
|
||||
|
||||
export const api = {
|
||||
|
||||
@@ -14,10 +14,7 @@ export const fileAPI = {
|
||||
* @param {Array} items - 待删除项 [{type: 'file'|'folder', path: 'path'}]
|
||||
*/
|
||||
async delete(libraryId, items) {
|
||||
return api.delete('/file/delete', {
|
||||
body: JSON.stringify({ libraryId, items }),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
return api.delete('/file/delete', { libraryId, items });
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user