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