Files
aurora-admin/frameworks/ImagePreview.vue3.vue
T

29 lines
1.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="aa-imgprev-mask" v-if="visible" @click.self="emit('close')">
<button class="aa-imgprev-close" @click="emit('close')">✕</button>
<button class="aa-imgprev-arrow prev" @click="go(-1)">‹</button>
<img class="aa-imgprev-img" :src="images[index]" :alt="index" />
<button class="aa-imgprev-arrow next" @click="go(1)">›</button>
<div class="aa-imgprev-count">{{ index + 1 }} / {{ images.length }}</div>
<div class="aa-imgprev-thumbs">
<img v-for="(u, i) in images" :key="i" class="aa-imgprev-thumb" :class="{ 'is-active': i === index }"
:src="u" @click="emit('change', i)" />
</div>
</div>
</template>
<script setup>
const props = defineProps({
images: { type: Array, default: () => [] },
visible: { type: Boolean, default: false },
index: { type: Number, default: 0 }
});
const emit = defineEmits(['close', 'change']);
function go(dir) {
const len = props.images.length || 1;
emit('change', (props.index + dir + len) % len);
}
</script>
<style src="./ImagePreview.css"></style>