提交 87a7d538 编写于 作者: zhaosheng.zhang's avatar zhaosheng.zhang

fix: 上传视频优化

上级 90e713de
...@@ -68,12 +68,6 @@ export default { ...@@ -68,12 +68,6 @@ export default {
}, },
watch: { watch: {
imgList(newv) { imgList(newv) {
// 接口返回的视频格式第一帧,作为图片显示
newv.forEach((item) => {
if (this.isVideoFormat(item?.url)) {
this.getVideoCover(item);
}
});
this.imgArr = newv; this.imgArr = newv;
}, },
}, },
...@@ -114,7 +108,8 @@ export default { ...@@ -114,7 +108,8 @@ export default {
isVideoStatus(file) { isVideoStatus(file) {
this.isVideo = true; this.isVideo = true;
this.isImage = false; this.isImage = false;
this.getVideoCover(file); this.dialogVideoUrl = file.url;
// this.getVideoCover(file);
}, },
isImageURL(url) { isImageURL(url) {
return /\.(jpg|jpeg|png)$/i.test(url); return /\.(jpg|jpeg|png)$/i.test(url);
...@@ -132,7 +127,7 @@ export default { ...@@ -132,7 +127,7 @@ export default {
}, },
sucess(response, file, fileList) { sucess(response, file, fileList) {
console.log(response); console.log(response);
this.getVideoCover(file); // this.getVideoCover(file);
this.imgArr = fileList; this.imgArr = fileList;
}, },
setNewArr() { setNewArr() {
...@@ -179,7 +174,7 @@ export default { ...@@ -179,7 +174,7 @@ export default {
// 利用canvas对象方法绘图 // 利用canvas对象方法绘图
ctx.drawImage(video, 0, 0, canvas.width, canvas.height); ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
// 转换成base64形式 // 转换成base64形式
const videoFirstimgsrc = canvas.toDataURL('image/png'); // 截取后的视频封面 const videoFirstimgsrc = canvas.toDataURL('image/*'); // 截取后的视频封面
const videoUrl = file.url; const videoUrl = file.url;
file.url = videoFirstimgsrc; // file的url储存封面图片 file.url = videoFirstimgsrc; // file的url储存封面图片
this.dialogVideoUrl = videoUrl; this.dialogVideoUrl = videoUrl;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册