fix creater,editor preview
This commit is contained in:
@ -160,14 +160,22 @@ Page({
|
||||
})
|
||||
},
|
||||
preview(e: WechatMiniprogram.BaseEvent) {
|
||||
const itemIndex = e.currentTarget.dataset.index;
|
||||
const total = this.data.mediaList.length;
|
||||
|
||||
const startIndex = Math.max(0, itemIndex - 25);
|
||||
const endIndex = Math.min(total, startIndex + 50);
|
||||
const newCurrentIndex = itemIndex - startIndex;
|
||||
|
||||
const sources = this.data.mediaList.slice(startIndex, endIndex).map(item => {
|
||||
return {
|
||||
url: item.path,
|
||||
type: MediaItemType[item.type].toLowerCase()
|
||||
} as WechatMiniprogram.MediaSource;
|
||||
});
|
||||
wx.previewMedia({
|
||||
current: e.currentTarget.dataset.index,
|
||||
sources: this.data.mediaList.map(item => {
|
||||
return {
|
||||
url: item.path,
|
||||
type: MediaItemType[item.type].toLowerCase()
|
||||
} as WechatMiniprogram.MediaSource;
|
||||
})
|
||||
current: newCurrentIndex,
|
||||
sources
|
||||
});
|
||||
},
|
||||
deleteMedia(e: WechatMiniprogram.BaseEvent) {
|
||||
|
||||
@ -196,10 +196,16 @@ Page({
|
||||
type: MediaItemType[item.type].toLowerCase()
|
||||
}));
|
||||
const allSources = [...sources, ...newSources];
|
||||
const currentIndex = isNewMedia ? this.data.mediaList.length + index : index;
|
||||
const itemIndex = isNewMedia ? this.data.mediaList.length + index : index;
|
||||
const total = allSources.length;
|
||||
|
||||
const startIndex = Math.max(0, itemIndex - 25);
|
||||
const endIndex = Math.min(total, startIndex + 50);
|
||||
const newCurrentIndex = itemIndex - startIndex;
|
||||
|
||||
wx.previewMedia({
|
||||
current: currentIndex,
|
||||
sources: allSources as WechatMiniprogram.MediaSource[]
|
||||
current: newCurrentIndex,
|
||||
sources: allSources.slice(startIndex, endIndex) as WechatMiniprogram.MediaSource[]
|
||||
});
|
||||
},
|
||||
/** 删除附件 */
|
||||
|
||||
Reference in New Issue
Block a user