fix(uploader): fix preview video index error (#5142)

This commit is contained in:
landluck 2022-12-14 10:25:36 +08:00 committed by GitHub
parent 91a12bbaaf
commit 33e1725b0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -186,14 +186,25 @@ VantComponent({
const { index } = event.currentTarget.dataset;
const { lists } = this.data as { lists: File[] };
const sources: WechatMiniprogram.MediaSource[] = [];
const current = lists.reduce((sum, cur, curIndex) => {
if (!isVideoFile(cur)) {
return sum;
}
sources.push({ ...cur, type: 'video' });
if (curIndex < index) {
sum++;
}
return sum;
}, 0);
wx.previewMedia({
sources: lists
.filter((item) => isVideoFile(item))
.map((item) => ({
...item,
type: 'video',
})),
current: index,
sources,
current,
fail() {
wx.showToast({ title: '预览视频失败', icon: 'none' });
},