<template>
|
<div class="image-grid-wrapper">
|
<nut-grid square :gutter="gutter" :column-num="columnNum" :center="false">
|
<nut-grid-item
|
v-for="item in images"
|
:key="item.src"
|
class="image-grid-file-list-item-wrapper"
|
>
|
<div class="image-grid-file-list-item img-grid">
|
<PreviewImage
|
:src="setOSSLink(item.src)"
|
class="image-grid-img"
|
wrapperClassName="image-grid-img-wrapper"
|
:urls="previewUrls"
|
/>
|
</div>
|
</nut-grid-item>
|
</nut-grid>
|
<!-- <div v-else-if="images.length === 1" class="image-grid-file-list-item img">
|
<AutoWidthImage
|
wrapperClassName="image-normal-img"
|
openScale
|
:src="setOSSLink(images[0].src)"
|
/>
|
</div> -->
|
</div>
|
</template>
|
|
<script setup lang="ts">
|
import AutoWidthImage from './AutoWidthImage.vue';
|
import PreviewImage from './PreviewImage.vue';
|
import { setOSSLink } from '@12333/utils';
|
import { computed } from 'vue';
|
|
defineOptions({
|
name: 'ImageGrid',
|
});
|
|
type Props = {
|
imageList: {
|
fileUrl?: string;
|
[key: string]: any;
|
}[];
|
gutter?: number;
|
columnNum?: number;
|
};
|
|
const props = withDefaults(defineProps<Props>(), {
|
gutter: 20,
|
columnNum: 3,
|
});
|
|
const images = computed(() =>
|
props.imageList.map((item) => ({
|
src: setOSSLink(item.fileUrl),
|
}))
|
);
|
|
const previewUrls = computed(() => images.value.map((item) => item.src));
|
</script>
|
|
<style lang="scss">
|
@import '@/styles/common.scss';
|
|
.image-grid-wrapper {
|
// margin: -10px;
|
// display: flex;
|
// flex-wrap: wrap;
|
margin-bottom: 20px;
|
width: 100%;
|
|
.nut-grid {
|
padding: 0 !important;
|
width: 100%;
|
}
|
|
.image-grid-file-list-item-wrapper {
|
.nut-grid-item__content--square {
|
padding: 0;
|
border: none;
|
display: block;
|
}
|
}
|
|
.image-grid-file-list-item {
|
padding: 5px;
|
box-sizing: border-box;
|
|
&.video {
|
// width: 300px;
|
// height: 150px;
|
max-width: 66%;
|
}
|
|
&.img {
|
// width: 450px;
|
// max-height: 400px;
|
overflow: hidden;
|
// height: auto;
|
// height: 150px;
|
width: 66%;
|
display: flex;
|
}
|
|
&.img-grid {
|
// width: 33%;
|
width: 100%;
|
height: 100%;
|
}
|
|
.image-grid-img-wrapper {
|
overflow: hidden;
|
@include hairline-surround;
|
box-sizing: border-box;
|
border-radius: 8px;
|
}
|
|
.image-grid-img {
|
width: 100%;
|
height: 100%;
|
/* object-fit: cover; */
|
}
|
|
.image-normal-img {
|
@include hairline-surround;
|
width: auto;
|
height: auto;
|
}
|
|
.image-grid-video {
|
width: 100%;
|
height: 100%;
|
}
|
}
|
}
|
</style>
|