fix: 增加上传处理
This commit is contained in:
parent
97f9560c4d
commit
ae74af59fc
@ -7,6 +7,7 @@
|
|||||||
:file-list="fileList"
|
:file-list="fileList"
|
||||||
:data="uploadData"
|
:data="uploadData"
|
||||||
:on-progress="() => (uploading = true)"
|
:on-progress="() => (uploading = true)"
|
||||||
|
:on-error="(err: Error) => message.error(`上传失败: ${err.message}`)"
|
||||||
:before-upload="beforeUpload"
|
:before-upload="beforeUpload"
|
||||||
:on-success="handleUploadSuccess"
|
:on-success="handleUploadSuccess"
|
||||||
>
|
>
|
||||||
@ -33,7 +34,7 @@ import {
|
|||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
|
|
||||||
const props = defineProps<{ type: boolean }>()
|
const props = defineProps<{ type: MaterialType }>()
|
||||||
|
|
||||||
const fileList = ref<UploadUserFile[]>([])
|
const fileList = ref<UploadUserFile[]>([])
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
@ -47,7 +48,7 @@ const uploadData: UploadData = reactive({
|
|||||||
})
|
})
|
||||||
const uploading = ref(false)
|
const uploading = ref(false)
|
||||||
|
|
||||||
const beforeUpload = props.type == MaterialType.Image ? beforeImageUpload : beforeVoiceUpload
|
const beforeUpload = props.type === MaterialType.Image ? beforeImageUpload : beforeVoiceUpload
|
||||||
|
|
||||||
const handleUploadSuccess: UploadProps['onSuccess'] = (res: any) => {
|
const handleUploadSuccess: UploadProps['onSuccess'] = (res: any) => {
|
||||||
if (res.code !== 0) {
|
if (res.code !== 0) {
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
:data="uploadData"
|
:data="uploadData"
|
||||||
:before-upload="beforeVideoUpload"
|
:before-upload="beforeVideoUpload"
|
||||||
:on-progress="() => (uploading = true)"
|
:on-progress="() => (uploading = true)"
|
||||||
|
:on-error="(err: Error) => message.error(`上传失败: ${err.message}`)"
|
||||||
:on-success="handleUploadSuccess"
|
:on-success="handleUploadSuccess"
|
||||||
ref="uploadVideoRef"
|
ref="uploadVideoRef"
|
||||||
:auto-upload="false"
|
:auto-upload="false"
|
||||||
|
Loading…
Reference in New Issue
Block a user