feat: 是否在组件Unmounted时取消上传
This commit is contained in:
@@ -20,18 +20,21 @@ export interface UploadResult {
|
||||
* 通过单文件上传接口
|
||||
* @param file 上传的文件
|
||||
* @param otherData 其他请求参数 后端拓展可能会用到
|
||||
* @param onUploadProgress 上传进度事件 非必传
|
||||
* @param options 一些配置项
|
||||
* @param options.onUploadProgress 上传进度事件
|
||||
* @param options.signal 上传取消信号
|
||||
* @returns 上传结果
|
||||
*/
|
||||
export function uploadApi(
|
||||
file: Blob | File,
|
||||
otherData?: Record<string, any>,
|
||||
onUploadProgress?: AxiosProgressEvent,
|
||||
options?: { onUploadProgress?: AxiosProgressEvent; signal?: AbortSignal },
|
||||
) {
|
||||
const { onUploadProgress, signal } = options ?? {};
|
||||
return requestClient.upload<UploadResult>(
|
||||
'/resource/oss/upload',
|
||||
{ file, ...otherData },
|
||||
{ onUploadProgress, timeout: 60_000 },
|
||||
{ onUploadProgress, signal, timeout: 60_000 },
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user