新增 文件操作 删除撤回功能

This commit is contained in:
Chen committed 2025-12-05 23:02:46 +08:00
1 parent 395b469d96
commit 740d0d28a2
16 files changed
+1812 -41

No files matched your search

+94
View File
@@ -0,0 +1,94 @@
/**
* 文件操作 API 客户端
*/
import axios from 'axios';
const API_BASE = import.meta.env.VITE_API_BASE || 'http://localhost:15002';
export const fileAPI = {
/**
* 删除文件或文件夹(移到临时文件夹,5分钟内可撤销)
* @param {string} libraryId - 素材库ID
* @param {Array} items - 待删除项 [{type: 'file'|'folder', path: 'path'}]
*/
async delete(libraryId, items) {
const response = await axios.delete(`${API_BASE}/api/file/delete`, {
data: { libraryId, items }
});
return response.data;
},
/**
* 重命名文件或文件夹
* @param {string} libraryId - 素材库ID
* @param {string} path - 文件路径
* @param {string} newName - 新名称
*/
async rename(libraryId, path, newName) {
const response = await axios.patch(`${API_BASE}/api/file/rename`, {
libraryId,
path,
newName
});
return response.data;
},
/**
* 移动文件或文件夹
* @param {string} libraryId - 素材库ID
* @param {Array} items - 待移动项
* @param {string} targetFolder - 目标文件夹路径
*/
async move(libraryId, items, targetFolder) {
const response = await axios.post(`${API_BASE}/api/file/move`, {
libraryId,
items,
targetFolder
});
return response.data;
},
/**
* 复制文件或文件夹
* @param {string} libraryId - 素材库ID
* @param {Array} items - 待复制项
* @param {string} targetFolder - 目标文件夹路径
*/
async copy(libraryId, items, targetFolder) {
const response = await axios.post(`${API_BASE}/api/file/copy`, {
libraryId,
items,
targetFolder
});
return response.data;
},
/**
* 更新文件元数据(评分、收藏、标签)
* @param {string} libraryId - 素材库ID
* @param {string} path - 文件路径
* @param {Object} metadata - 元数据 {rating?, favorite?, tags?}
*/
async updateMetadata(libraryId, path, metadata) {
const response = await axios.patch(`${API_BASE}/api/file/metadata`, {
libraryId,
path,
...metadata
});
return response.data;
},
/**
* 恢复文件或文件夹(从临时备份恢复)
* @param {string} libraryId - 素材库ID
* @param {Array} items - 待恢复项 [{type: 'file'|'folder', path: 'path'}]
*/
async restore(libraryId, items) {
const response = await axios.post(`${API_BASE}/api/file/restore`, {
libraryId,
items
});
return response.data;
}
};
+2
View File
@@ -5,10 +5,12 @@
import * as library from './endpoints/library';
import * as image from './endpoints/image';
import * as scan from './endpoints/scan';
import { fileAPI } from './file';
export const libraryAPI = library;
export const imageAPI = image;
export const scanAPI = scan;
export { fileAPI };
export { api, APIError } from './client';