fix: 修复媒体预览和反馈页面的交互问题
- 将click事件替换为tap事件以提升移动端体验 - 修复图片预览初始化索引不正确的问题 - 优化缩略图显示和删除按钮样式 - 移除多余的thumbnail回退逻辑
Showing
3 changed files
with
10 additions
and
8 deletions
| ... | @@ -30,7 +30,7 @@ export function useMediaPreview() { | ... | @@ -30,7 +30,7 @@ export function useMediaPreview() { |
| 30 | if (item.media_type === 'IMAGE') { | 30 | if (item.media_type === 'IMAGE') { |
| 31 | // 图片预览 | 31 | // 图片预览 |
| 32 | const imageItems = mediaList.filter(media => media.media_type === 'IMAGE'); | 32 | const imageItems = mediaList.filter(media => media.media_type === 'IMAGE'); |
| 33 | - previewImages.value = imageItems.map(img => ({ | 33 | + previewImages.value = imageItems.map(img => ({ |
| 34 | src: img.media_url, | 34 | src: img.media_url, |
| 35 | id: img.id, | 35 | id: img.id, |
| 36 | thumbnail: img.thumbnail, | 36 | thumbnail: img.thumbnail, | ... | ... |
| ... | @@ -84,7 +84,7 @@ | ... | @@ -84,7 +84,7 @@ |
| 84 | > | 84 | > |
| 85 | <!-- 关闭按钮 --> | 85 | <!-- 关闭按钮 --> |
| 86 | <view | 86 | <view |
| 87 | - @click.stop="closeVideo" | 87 | + @tap.stop="closeVideo" |
| 88 | class="absolute top-4 right-4 w-10 h-10 bg-black bg-opacity-50 rounded-full flex items-center justify-center" | 88 | class="absolute top-4 right-4 w-10 h-10 bg-black bg-opacity-50 rounded-full flex items-center justify-center" |
| 89 | style="z-index: 10000;" | 89 | style="z-index: 10000;" |
| 90 | > | 90 | > |
| ... | @@ -104,7 +104,7 @@ | ... | @@ -104,7 +104,7 @@ |
| 104 | :object-fit="'contain'" | 104 | :object-fit="'contain'" |
| 105 | :show-fullscreen-btn="true" | 105 | :show-fullscreen-btn="true" |
| 106 | style="width: 100vw; height: 50vh; position: absolute; top: 20vh; left: 0;" | 106 | style="width: 100vw; height: 50vh; position: absolute; top: 20vh; left: 0;" |
| 107 | - @click.stop | 107 | + @tap.stop |
| 108 | @play="handleVideoPlay" | 108 | @play="handleVideoPlay" |
| 109 | @pause="handleVideoPause" | 109 | @pause="handleVideoPause" |
| 110 | @error="handleVideoError" | 110 | @error="handleVideoError" |
| ... | @@ -172,7 +172,7 @@ const fetchAlbumList = async () => { | ... | @@ -172,7 +172,7 @@ const fetchAlbumList = async () => { |
| 172 | id: item.id, | 172 | id: item.id, |
| 173 | type: item.media_type === 'IMAGE' ? 'image' : 'video', | 173 | type: item.media_type === 'IMAGE' ? 'image' : 'video', |
| 174 | url: item.media_url, | 174 | url: item.media_url, |
| 175 | - thumbnail: item.thumbnail || item.media_url, // 使用thumbnail字段,如果没有则使用media_url | 175 | + thumbnail: item.thumbnail, |
| 176 | is_my: item.is_my, | 176 | is_my: item.is_my, |
| 177 | media_type: item.media_type, | 177 | media_type: item.media_type, |
| 178 | media_url: item.media_url | 178 | media_url: item.media_url | ... | ... |
| ... | @@ -28,14 +28,14 @@ | ... | @@ -28,14 +28,14 @@ |
| 28 | <image | 28 | <image |
| 29 | :src="item.url" | 29 | :src="item.url" |
| 30 | class="w-24 h-24 rounded-lg object-cover" | 30 | class="w-24 h-24 rounded-lg object-cover" |
| 31 | - mode="widthFix" | 31 | + mode="aspectFill" |
| 32 | @tap="() => previewImage(index)" | 32 | @tap="() => previewImage(index)" |
| 33 | /> | 33 | /> |
| 34 | <view | 34 | <view |
| 35 | @click="() => deleteImage(index)" | 35 | @click="() => deleteImage(index)" |
| 36 | - class="absolute -top-2 -right-2 w-4 h-4 bg-red-500 rounded-full flex items-center justify-center" | 36 | + class="absolute -top-1 -right-1 w-4 h-4 bg-red-500 rounded-full flex items-center justify-center" |
| 37 | > | 37 | > |
| 38 | - <view class="text-white text-xs">×</view> | 38 | + <view class="text-white" style="font-size: 24rpx; line-height: 24rpx">×</view> |
| 39 | </view> | 39 | </view> |
| 40 | </view> | 40 | </view> |
| 41 | <!-- 上传按钮 --> | 41 | <!-- 上传按钮 --> |
| ... | @@ -100,7 +100,7 @@ | ... | @@ -100,7 +100,7 @@ |
| 100 | <nut-image-preview | 100 | <nut-image-preview |
| 101 | v-model:show="previewVisible" | 101 | v-model:show="previewVisible" |
| 102 | :images="previewImages" | 102 | :images="previewImages" |
| 103 | - :init-no="0" | 103 | + :init-no="currentPreviewIndex" |
| 104 | @close="closePreview" | 104 | @close="closePreview" |
| 105 | /> | 105 | /> |
| 106 | </view> | 106 | </view> |
| ... | @@ -119,6 +119,7 @@ const name = ref(''); | ... | @@ -119,6 +119,7 @@ const name = ref(''); |
| 119 | const contact = ref(''); | 119 | const contact = ref(''); |
| 120 | const previewVisible = ref(false); | 120 | const previewVisible = ref(false); |
| 121 | const previewImages = ref([]); | 121 | const previewImages = ref([]); |
| 122 | +const currentPreviewIndex = ref(0); | ||
| 122 | const maxImages = 3; | 123 | const maxImages = 3; |
| 123 | 124 | ||
| 124 | /** | 125 | /** |
| ... | @@ -220,6 +221,7 @@ const uploadImage = (filePath) => { | ... | @@ -220,6 +221,7 @@ const uploadImage = (filePath) => { |
| 220 | */ | 221 | */ |
| 221 | const previewImage = (index) => { | 222 | const previewImage = (index) => { |
| 222 | previewImages.value = screenshots.value.map(item => ({ src: item.url })); | 223 | previewImages.value = screenshots.value.map(item => ({ src: item.url })); |
| 224 | + currentPreviewIndex.value = index; | ||
| 223 | previewVisible.value = true; | 225 | previewVisible.value = true; |
| 224 | }; | 226 | }; |
| 225 | 227 | ... | ... |
-
Please register or login to post a comment