fix: 优化排序媒体图片预览
This commit is contained in:
@@ -117,11 +117,21 @@ function remove(i: number) {
|
||||
emit('update:modelValue', list.value.filter((_, idx) => idx !== i));
|
||||
}
|
||||
|
||||
function toViewerItem(m: MediaItem) {
|
||||
return { url: m.url || m.key, name: m.name || m.key, type: m.type };
|
||||
}
|
||||
|
||||
function preview(index: number) {
|
||||
void openMediaViewer(
|
||||
list.value.map((m) => ({ url: m.url || m.key, name: m.name || m.key, type: m.type })),
|
||||
index,
|
||||
);
|
||||
const current = list.value[index];
|
||||
if (!current) return;
|
||||
if (isVideo(current)) {
|
||||
void openMediaViewer(list.value.map(toViewerItem), index);
|
||||
return;
|
||||
}
|
||||
|
||||
const imageList = list.value.filter((m) => !isVideo(m));
|
||||
const imageIndex = imageList.findIndex((m) => m === current);
|
||||
void openMediaViewer(imageList.map(toViewerItem), Math.max(imageIndex, 0));
|
||||
}
|
||||
|
||||
const dragIndex = ref<number | null>(null);
|
||||
|
||||
Reference in New Issue
Block a user