File size: 815 Bytes
e1ce1f2
a206d0f
e1ce1f2
 
 
 
 
 
 
 
 
c0a6b20
e1ce1f2
c0a6b20
e1ce1f2
 
 
 
 
 
 
 
 
a206d0f
 
e1ce1f2
 
 
 
a206d0f
 
e1ce1f2
 
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
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}`
  }
}