Files
admin-sjzx/src/api/system-boot/file.ts

78 lines
1.8 KiB
TypeScript
Raw Normal View History

2025-09-26 10:59:37 +08:00
import createAxios from '@/utils/request'
2025-12-15 10:35:34 +08:00
import { ElMessage } from 'element-plus'
2025-09-26 10:59:37 +08:00
const SYSTEM_PREFIX = '/system-boot'
/**
*
* @param file
*/
export const uploadFile = (file: any, path: string) => {
let form = new FormData()
form.append('file', file)
form.append('path', path)
return createAxios({
url: SYSTEM_PREFIX + '/file/upload',
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data'
},
data: form
2025-12-15 10:35:34 +08:00
}).then(res => {
if (res.code == `A0000`) {
ElMessage.success('上传成功!')
return res
}
2025-09-26 10:59:37 +08:00
})
}
/**
*
*/
export const deleteFile = (filePath: string) => {
let form = new FormData()
form.append('filePath', filePath)
return createAxios({
url: SYSTEM_PREFIX + '/file/delete',
method: 'POST',
data: form
})
}
/**
*
*/
export const downloadFile = (filePath: any) => {
// let form = new FormData()
// form.append('filePath', filePath)
return createAxios({
url: SYSTEM_PREFIX + '/file/download',
method: 'GET',
params: filePath,
responseType: 'blob'
})
}
/**
* url展示
*/
2025-12-15 10:35:34 +08:00
export const getFileUrl = (params: any) => {
2025-09-26 10:59:37 +08:00
let form = new FormData()
// form.append('filePath', filePath)
return createAxios({
url: SYSTEM_PREFIX + '/file/getFileUrl',
method: 'get',
params
})
}
/**
* url及文件名
*/
export const getFileNameAndFilePath = (query: any) => {
return createAxios({
url: SYSTEM_PREFIX + '/file/getFileVO',
method: 'GET',
params: query
})
}