Commit 1e99a8b3 by yancanhua

fix: 视频播放优化

1 parent 6e977361
Pipeline #184 for 1e99a8b3 failed in 0 seconds
...@@ -77,6 +77,11 @@ async function onFileChange(ev: Event) { ...@@ -77,6 +77,11 @@ async function onFileChange(ev: Event) {
function handleDelete(item: string) { function handleDelete(item: string) {
pickerValue.value = pickerValue.value.filter((i) => i !== item); pickerValue.value = pickerValue.value.filter((i) => i !== item);
console.log("pickerValue.value111111111111111", pickerValue.value);
// 清除视频预览状态,防止缓存
sourceSrcUrl.value = "";
sourceUrl.value = [];
videoShow.value = false;
updateData(); updateData();
} }
...@@ -100,9 +105,15 @@ function previewImage(url: string) { ...@@ -100,9 +105,15 @@ function previewImage(url: string) {
// 视频预览 // 视频预览
const videoShow = ref(false); const videoShow = ref(false);
const sourceUrl = ref([]); const sourceUrl = ref([]);
const sourceSrcUrl = ref("");
function previewVideo(url: string) { function previewVideo(url: string) {
sourceUrl.value = [url]; // 添加时间戳参数,防止浏览器缓存
const timestamp = new Date().getTime();
const urlWithTimestamp = url.includes('?') ? `${url}&t=${timestamp}` : `${url}?t=${timestamp}`;
sourceSrcUrl.value = urlWithTimestamp;
sourceUrl.value = [urlWithTimestamp];
console.log("sourceUrl.value", sourceUrl.value); console.log("sourceUrl.value", sourceUrl.value);
videoShow.value = true; videoShow.value = true;
} }
...@@ -124,7 +135,7 @@ function previewVideo(url: string) { ...@@ -124,7 +135,7 @@ function previewVideo(url: string) {
</van-overlay> </van-overlay>
<!-- 图片预览 --> <!-- 图片预览 -->
<van-image-preview v-model:show="imagePreview" :images="previewImagesList"></van-image-preview> <van-image-preview v-model:show="imagePreview" :closeable="true" :close-on-click-image="false" :images="previewImagesList"></van-image-preview>
<!-- 视频预览 --> <!-- 视频预览 -->
<van-image-preview v-model:show="videoShow" <van-image-preview v-model:show="videoShow"
...@@ -133,7 +144,7 @@ function previewVideo(url: string) { ...@@ -133,7 +144,7 @@ function previewVideo(url: string) {
:images="sourceUrl"> :images="sourceUrl">
<template #image="{ src }"> <template #image="{ src }">
<video controls style="width: 100%;"> <video controls style="width: 100%;">
<source :src="src" /> <source :src="sourceSrcUrl" />
</video> </video>
</template> </template>
</van-image-preview> </van-image-preview>
...@@ -178,10 +189,8 @@ function previewVideo(url: string) { ...@@ -178,10 +189,8 @@ function previewVideo(url: string) {
<!-- 图片 --> <!-- 图片 -->
<van-image v-if="item.interactionType == 'image_upload'" <van-image v-if="item.interactionType == 'image_upload'"
class="uploadBoxImg" class="uploadBoxImg"
height="96"
radius="8px" radius="8px"
:src="url" :src="url"
width="96"
@click="previewImage(url)" /> @click="previewImage(url)" />
<!-- 视频 --> <!-- 视频 -->
<video v-if="item.interactionType == 'video_upload'" <video v-if="item.interactionType == 'video_upload'"
...@@ -263,12 +272,14 @@ function previewVideo(url: string) { ...@@ -263,12 +272,14 @@ function previewVideo(url: string) {
margin-right: 12px; margin-right: 12px;
margin-bottom: 16px; margin-bottom: 16px;
background: #f9f9f9; background: #f9f9f9;
border: 1px solid #f9f9f9;
border-radius: 8px; border-radius: 8px;
} }
.uploadBoxImg { .uploadBoxImg {
width: 96px; width: 100%;
height: 96px; height: 100%;
z-index: 9;
border-radius: 8px; border-radius: 8px;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!