85 lines
1.8 KiB
Vue
Raw Normal View History

<template>
2024-07-19 15:45:18 +08:00
<div class="square-container">
<el-input
v-model="searchText"
style="width: 100%;margin-bottom: 20px;"
size="large"
placeholder="请输入要搜索的内容"
:suffix-icon="Search"
@keyup.enter="handleSearch"
/>
<div class="gallery">
<div v-for="item in publicList" :key="item" class="gallery-item">
<img :src="item.picUrl" class="img"/>
</div>
2024-07-17 08:50:06 +08:00
</div>
</div>
</template>
<script setup lang="ts">
2024-07-17 13:49:06 +08:00
import { ImageApi, ImageVO, ImageMidjourneyButtonsVO } from '@/api/ai/image'
2024-07-19 15:45:18 +08:00
import {Search} from "@element-plus/icons-vue";
/** 属性 */
const pageNo = ref<number>(1)
const pageSize = ref<number>(20)
const publicList = ref<ImageVO[]>([])
2024-07-19 15:45:18 +08:00
const searchText = ref<string>('')
/** 获取数据 */
const getListData = async () => {
2024-07-19 15:45:18 +08:00
const res = await ImageApi.getImagePagePublic({pageNo: pageNo.value, pageSize: pageSize.value, prompt: searchText.value});
2024-07-17 13:49:06 +08:00
publicList.value = res.list as ImageVO[];
2024-07-19 15:45:18 +08:00
}
/** 搜索 */
const handleSearch = async () => {
await getListData();
}
onMounted(async () => {
await getListData()
})
</script>
<style scoped lang="scss">
2024-07-17 13:49:06 +08:00
2024-07-19 15:45:18 +08:00
.square-container {
2024-07-17 13:49:06 +08:00
background-color: #fff;
2024-07-19 15:45:18 +08:00
padding: 20px;
2024-07-17 13:49:06 +08:00
2024-07-19 15:45:18 +08:00
.gallery {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 10px;
//max-width: 1000px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
2024-07-17 13:49:06 +08:00
2024-07-19 15:45:18 +08:00
.gallery-item {
position: relative;
overflow: hidden;
background: #f0f0f0;
cursor: pointer;
transition: transform 0.3s;
}
.gallery-item img {
width: 100%;
height: auto;
display: block;
transition: transform 0.3s;
}
.gallery-item:hover img {
transform: scale(1.1);
}
.gallery-item:hover {
transform: scale(1.05);
}
}
2024-07-17 13:49:06 +08:00
</style>