72 lines
1.4 KiB
Vue
72 lines
1.4 KiB
Vue
|
|
<!-- ImagePreview.vue -->
|
|||
|
|
<template>
|
|||
|
|
<div v-if="modelValue" class="image-preview-modal" @click="closePreview">
|
|||
|
|
<div class="image-preview-container" @click.stop>
|
|||
|
|
<img :src="url" alt="Preview Image" class="preview-image" />
|
|||
|
|
<button class="close-btn" @click="closePreview">×</button>
|
|||
|
|
</div>
|
|||
|
|
</div>
|
|||
|
|
</template>
|
|||
|
|
|
|||
|
|
<script setup lang="ts">
|
|||
|
|
import { computed } from 'vue'
|
|||
|
|
|
|||
|
|
const props = defineProps<{
|
|||
|
|
url: string
|
|||
|
|
modelValue: boolean
|
|||
|
|
}>()
|
|||
|
|
|
|||
|
|
const emits = defineEmits(['update:modelValue'])
|
|||
|
|
|
|||
|
|
const closePreview = () => {
|
|||
|
|
emits('update:modelValue', false)
|
|||
|
|
}
|
|||
|
|
</script>
|
|||
|
|
|
|||
|
|
<style lang="less" scoped>
|
|||
|
|
.image-preview-modal {
|
|||
|
|
position: fixed;
|
|||
|
|
top: 0;
|
|||
|
|
left: 0;
|
|||
|
|
width: 100vw;
|
|||
|
|
height: 100vh;
|
|||
|
|
background-color: rgba(0, 0, 0, 0.8);
|
|||
|
|
display: flex;
|
|||
|
|
align-items: center;
|
|||
|
|
justify-content: center;
|
|||
|
|
z-index: 1000;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.image-preview-container {
|
|||
|
|
position: relative;
|
|||
|
|
max-width: 90vw;
|
|||
|
|
max-height: 90vh;
|
|||
|
|
display: flex;
|
|||
|
|
justify-content: center;
|
|||
|
|
align-items: center;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.preview-image {
|
|||
|
|
max-width: 100%;
|
|||
|
|
max-height: 90vh;
|
|||
|
|
border-radius: 0.8rem;
|
|||
|
|
display: block;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
.close-btn {
|
|||
|
|
position: absolute;
|
|||
|
|
top: -2rem;
|
|||
|
|
right: -2rem;
|
|||
|
|
background: white;
|
|||
|
|
border: none;
|
|||
|
|
font-size: 3rem;
|
|||
|
|
cursor: pointer;
|
|||
|
|
color: #606266;
|
|||
|
|
width: 4rem;
|
|||
|
|
height: 4rem;
|
|||
|
|
border-radius: 50%;
|
|||
|
|
display: flex;
|
|||
|
|
align-items: center;
|
|||
|
|
justify-content: center;
|
|||
|
|
}
|
|||
|
|
</style>
|