import { request } from "@/utils/service"

interface IResultUploadFile {
  code: number
  data: string
}

export function uploadFile(file: FormData, param: any) {
  return request<IResultUploadFile>({
    url: "https://dev-customcms.sud.tech/upload",
    method: "post",
    data: file,
    headers: {
      "Authorization": `eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIzMTM4MzczMTM3MzUzMjM1MzMzMDM0MzAzMTM0MzMzMTM1MzUzMiIsImVpZCI6IjMxMzczNjM1MzkzNTMyMzAzNDM5IiwibGlkIjoiMzEzNzM2MzUzOTMzMzczNjM0MzkzMCIsInJpZCI6IjMxMzczNjM1MzkzMzM3MzczNjM5In0.WdTO8FABRJ07roD_vNF_T575toNDWI1v1hxQvXDv9ro`,
      "Content-Type": "multipart/form-data"
    },
    // 获取上传的进度
    onUploadProgress: (event) => {
      param.file.percent = event.loaded / (event.total || 1) * 100
      // 此处调用处理中
      param.onProgress(param.file)
    }
  })
}
