feat: 大屏
This commit is contained in:
29
src/api/fts.ts
Normal file
29
src/api/fts.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { AxiosProgressEvent } from "axios";
|
||||
import axiosInstance from '@/api/axios'
|
||||
import { ContentTypeEnum } from '@/enums/httpEnum'
|
||||
|
||||
/** 上传文件 */
|
||||
const FtsUpload = (data: any, onUploadProgress?: (progress: number) => void) => {
|
||||
data.append('provider', 'local')
|
||||
data.append('bucket', 'visual')
|
||||
|
||||
// 使用完整URL,绕过 /Visual/v1 前缀
|
||||
const baseUrl = import.meta.env.PROD ? import.meta.env.VITE_PRO_PATH : import.meta.env.VITE_DEV_PATH
|
||||
|
||||
return axiosInstance({
|
||||
url: `${baseUrl}/fts/v1/uploader`,
|
||||
method: 'POST',
|
||||
data,
|
||||
headers: {
|
||||
'Content-Type': ContentTypeEnum.FORM_DATA
|
||||
},
|
||||
onUploadProgress: onUploadProgress ? (progressEvent: AxiosProgressEvent) => {
|
||||
if (progressEvent.total) {
|
||||
const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
|
||||
onUploadProgress(percentCompleted);
|
||||
}
|
||||
} : undefined
|
||||
})
|
||||
}
|
||||
|
||||
export default FtsUpload
|
||||
Reference in New Issue
Block a user