Browse Source

上传视频

master
zhang_li 12 months ago
parent
commit
1c0214c1f8
  1. 14
      src/components/UploadFile/src/UploadFile.vue

14
src/components/UploadFile/src/UploadFile.vue

@ -12,6 +12,7 @@
:headers="uploadHeaders"
:limit="props.limit"
:drag="drag"
:accept="fileType.join(',')"
:before-upload="beforeUpload"
:on-exceed="handleExceed"
:on-success="handleFileSuccess"
@ -26,8 +27,9 @@
大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b>
</div>
<div style="font-size: 8px;line-height: initial;">
格式为 <b style="color: #f56c6c">{{ fileType.join('/') }}</b> 的文件
格式为 <b style="color: #f56c6c">{{ fileType.join(',') }}</b> 的文件
</div>
<Preview/>
</template>
<template v-if="!isShowFile" #file >
<div>
@ -38,6 +40,7 @@
</template>
<script lang="ts" setup>
import { PropType } from 'vue'
import Preview from '@/components/UploadFile/src/Preview'
import { propTypes } from '@/utils/propTypes'
import { getAccessToken, getTenantId } from '@/utils/auth'
@ -60,15 +63,16 @@ const props = defineProps({
fileSize: propTypes.number.def(5), // (MB)
limit: propTypes.number.def(5), //
autoUpload: propTypes.bool.def(true), //
drag: propTypes.bool.def(false), //
isShowTip: propTypes.bool.def(true), //
isShowFile: propTypes.bool.def(true), //
})
console.log('props.upData',props.upData)
// ========== ==========
const valueRef = ref(props.modelValue)
const uploadRef = ref<UploadInstance>()
const uploadList = ref<UploadUserFile[]>([])
console.log('props.modelValue',props.modelValue)
const fileList = props.modelValue && props.modelValue.length > 0 ? ref<UploadUserFile[]>(props.modelValue) : ref<UploadUserFile[]>([])
const uploadNumber = ref<number>(0)
const uploadHeaders = ref({
@ -91,7 +95,7 @@ const beforeUpload: UploadProps['beforeUpload'] = (file: UploadRawFile) => {
})
const isLimit = file.size < props.fileSize * 1024 * 1024
if (!isImg) {
message.error(`文件格式不正确, 请上传${props.fileType.join('/')}格式!`)
message.error(`文件格式不正确, 请上传${props.fileType.join(',')}格式!`)
return false
}
if (!isLimit) {
@ -136,7 +140,9 @@ const handleRemove = (file) => {
}
}
const handlePreview: UploadProps['onPreview'] = (uploadFile) => {
console.log(uploadFile)
console.log('uploadFile',uploadFile)
window.open(uploadFile.url)
}
//
const listToString = (list: UploadUserFile[], separator?: string) => {

Loading…
Cancel
Save