fix:项目初始化
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
<!--
|
||||
* @Author: 王涛
|
||||
* @Mail: no
|
||||
* @Date: 2020-09-30 11:10:55
|
||||
* @LastEditors: 江涛
|
||||
* @LastEditTime: 2021-03-24 11:39:53
|
||||
-->
|
||||
<template>
|
||||
<uploader
|
||||
:options="options"
|
||||
class="uploader-example"
|
||||
@file-success="fileSuccess"
|
||||
@file-added="fileAdd">
|
||||
<uploader-unsupport></uploader-unsupport>
|
||||
<uploader-drop>
|
||||
<uploader-btn>选择文件</uploader-btn>
|
||||
</uploader-drop>
|
||||
<uploader-list></uploader-list>
|
||||
</uploader>
|
||||
</template>
|
||||
<script>
|
||||
// import { resumeUploadIsSuccess } from '@/api/video/video'
|
||||
import { videoOk } from '@/api/video.js'
|
||||
import { getToken } from '@/utils/auth'
|
||||
export default {
|
||||
props: {
|
||||
type: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 视频校验唯一码
|
||||
trackId: '',
|
||||
duration: 0
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
options() {
|
||||
return {
|
||||
target: '/api/web/mediafile/videoBody',
|
||||
method: 'application/json',
|
||||
chunkSize: 2 * 1024 * 1024,
|
||||
testChunks: false,
|
||||
forceChunkSize: true,
|
||||
maxChunkRetries: 3,
|
||||
singleFile: true,
|
||||
query: this.uploadQuery,
|
||||
headers: {
|
||||
Authorization: getToken()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
uploadQuery(file, chunk) {
|
||||
return {
|
||||
pos: chunk.offset,
|
||||
taskId: this.trackId,
|
||||
type: 1,
|
||||
data: 'flie'
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 上传视频-点击上传视频
|
||||
*/
|
||||
async fileSuccess(rootFile, file, message, chunk) {
|
||||
const video = document.createElement('video')
|
||||
video.preload = 'metadata'
|
||||
video.src = URL.createObjectURL(rootFile.file)
|
||||
video.onloadedmetadata = () => {
|
||||
window.URL.revokeObjectURL(video.src)
|
||||
// eslint-disable-next-line no-const-assign
|
||||
|
||||
this.duration = video.duration
|
||||
}
|
||||
|
||||
const data = {
|
||||
id: this.trackId,
|
||||
videoUrl: JSON.parse(message).data.videoUri
|
||||
}
|
||||
videoOk(data).then((res) => {
|
||||
if (res.code === 200) {
|
||||
const param = {
|
||||
id:video.id,
|
||||
width: video.videoWidth,
|
||||
height: video.videoHeight,
|
||||
duration: this.duration,
|
||||
videoUri: JSON.parse(message).data.videoUri,
|
||||
size: file.size
|
||||
}
|
||||
this.$emit('changeVideoUrl', param)
|
||||
} else {
|
||||
this.$message({
|
||||
type: 'error',
|
||||
message: '视频上传失败!'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
fileAdd() {
|
||||
this.trackId = new Date().getTime()+''
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user