import { http } from '@/utils/request' import { getApiBase } from '@/utils/apiBase' // 素材管理API export const materialApi = { // 获取所有素材 getAllMaterials: () => { return http.get('/getFiles') }, // 上传素材 uploadMaterial: (formData, onUploadProgress) => { // 使用http.upload方法,它已经配置了正确的Content-Type return http.upload('/uploadSave', formData, onUploadProgress) }, // 删除素材 deleteMaterial: (id) => { return http.get(`/deleteFile?id=${id}`) }, // 下载素材 downloadMaterial: (filePath) => { const b = getApiBase() return `${b}/download/${filePath}` }, // 获取素材预览URL getMaterialPreviewUrl: (filename) => { const b = getApiBase() return `${b}/getFile?filename=${filename}` } }