32 lines
977 B
TypeScript
Raw Normal View History

2023-04-15 15:59:33 +08:00
import type { UploadProps, UploadRawFile } from 'element-plus'
import { getAccessToken } from '@/utils/auth'
import { UploadType, useBeforeUpload } from '@/views/mp/hooks/useUpload'
2023-04-18 11:19:54 +08:00
2023-04-15 16:37:11 +08:00
const HEADERS = { Authorization: 'Bearer ' + getAccessToken() } // 请求头
const UPLOAD_URL = import.meta.env.VITE_BASE_URL + '/admin-api/mp/material/upload-permanent' // 上传地址
2023-04-15 15:59:33 +08:00
interface UploadData {
type: UploadType
2023-04-15 15:59:33 +08:00
title: string
introduction: string
}
const beforeImageUpload: UploadProps['beforeUpload'] = (rawFile: UploadRawFile) =>
useBeforeUpload(UploadType.Image, 2)(rawFile)
2023-04-15 15:59:33 +08:00
const beforeVoiceUpload: UploadProps['beforeUpload'] = (rawFile: UploadRawFile) =>
useBeforeUpload(UploadType.Voice, 2)(rawFile)
2023-04-15 15:59:33 +08:00
const beforeVideoUpload: UploadProps['beforeUpload'] = (rawFile: UploadRawFile) =>
useBeforeUpload(UploadType.Video, 10)(rawFile)
2023-04-15 15:59:33 +08:00
export {
HEADERS,
UPLOAD_URL,
UploadType,
2023-04-15 15:59:33 +08:00
UploadData,
beforeImageUpload,
beforeVoiceUpload,
beforeVideoUpload
}