Skip to content

Commit

Permalink
fix: 🐛 修复Upload组件accept为media时图片预览顺序混乱的问题
Browse files Browse the repository at this point in the history
Closes: #442
  • Loading branch information
xuqingkai committed Jul 16, 2024
1 parent ae91c28 commit f8c1053
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/uni_modules/wot-design-uni/components/wd-upload/wd-upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<view :class="['wd-upload__preview', customPreviewClass]" v-for="(file, index) in uploadFiles" :key="index">
<!-- 成功时展示图片 -->
<view class="wd-upload__status-content">
<image v-if="isImage(file)" :src="file.url" :mode="imageMode" class="wd-upload__picture" @click="onPreviewImage(index)" />
<image v-if="isImage(file)" :src="file.url" :mode="imageMode" class="wd-upload__picture" @click="onPreviewImage(file)" />
<template v-else-if="isVideo(file)">
<view class="wd-upload__video" v-if="file.thumb" @click="onPreviewVideo(file)">
<image :src="file.thumb" :mode="imageMode" class="wd-upload__picture" />
Expand Down Expand Up @@ -529,19 +529,27 @@ function handlePreviewVieo(index: number, lists: UploadFileItem[]) {
// #endif
}
function onPreviewImage(index: number) {
function onPreviewImage(file: UploadFileItem) {
const { beforePreview } = props
const lists = uploadFiles.value.filter((file) => isImage(file)).map((file) => file.url)
const lists = uploadFiles.value.filter((file) => isImage(file))
const index: number = lists.findIndex((item) => item.url === file.url)
if (beforePreview) {
beforePreview({
index,
imgList: lists,
imgList: lists.map((file) => file.url),
resolve: (isPass: boolean) => {
isPass && handlePreviewImage(index, lists)
isPass &&
handlePreviewImage(
index,
lists.map((file) => file.url)
)
}
})
} else {
handlePreviewImage(index, lists)
handlePreviewImage(
index,
lists.map((file) => file.url)
)
}
}
Expand Down

0 comments on commit f8c1053

Please sign in to comment.