Skip to content

Commit fcf948e

Browse files
committed
【增加】画廊增加 search
1 parent bd643f9 commit fcf948e

File tree

2 files changed

+54
-32
lines changed

2 files changed

+54
-32
lines changed

src/api/ai/image/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const ImageApi = {
5757
return await request.get({ url: `/ai/image/my-page`, params })
5858
},
5959
// 获取公开的绘图记录
60-
getImagePagePublic: async (params: PageParam) => {
60+
getImagePagePublic: async (params) => {
6161
return await request.get({ url: `/ai/image/public-page`, params })
6262
},
6363
// 获取【我的】绘图记录

src/views/ai/image/square/index.vue

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
11
<template>
2-
<div class="gallery">
3-
<div v-for="item in publicList" :key="item" class="gallery-item">
4-
<img :src="item.picUrl" class="img"/>
2+
<div class="square-container">
3+
<el-input
4+
v-model="searchText"
5+
style="width: 100%;margin-bottom: 20px;"
6+
size="large"
7+
placeholder="请输入要搜索的内容"
8+
:suffix-icon="Search"
9+
@keyup.enter="handleSearch"
10+
/>
11+
<div class="gallery">
12+
<div v-for="item in publicList" :key="item" class="gallery-item">
13+
<img :src="item.picUrl" class="img"/>
14+
</div>
515
</div>
616
</div>
717
</template>
818
<script setup lang="ts">
919
import { ImageApi, ImageVO, ImageMidjourneyButtonsVO } from '@/api/ai/image'
20+
import {Search} from "@element-plus/icons-vue";
1021
1122
/** 属性 */
1223
const pageNo = ref<number>(1)
1324
const pageSize = ref<number>(20)
1425
const publicList = ref<ImageVO[]>([])
26+
const searchText = ref<string>('')
1527
1628
/** 获取数据 */
1729
const getListData = async () => {
18-
const res = await ImageApi.getImagePagePublic({pageNo: pageNo.value, pageSize: pageSize.value});
30+
const res = await ImageApi.getImagePagePublic({pageNo: pageNo.value, pageSize: pageSize.value, prompt: searchText.value});
1931
publicList.value = res.list as ImageVO[];
20-
console.log('publicList.value', publicList.value)
32+
}
33+
34+
/** 搜索 */
35+
const handleSearch = async () => {
36+
await getListData();
2137
}
2238
2339
onMounted(async () => {
@@ -26,37 +42,43 @@ onMounted(async () => {
2642
</script>
2743
<style scoped lang="scss">
2844
29-
.gallery {
30-
display: grid;
31-
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
32-
gap: 10px;
33-
//max-width: 1000px;
34-
padding: 20px;
45+
.square-container {
3546
background-color: #fff;
36-
box-shadow: 0 0 10px rgba(0,0,0,0.1);
37-
}
47+
padding: 20px;
3848
39-
.gallery-item {
40-
position: relative;
41-
overflow: hidden;
42-
background: #f0f0f0;
43-
cursor: pointer;
44-
transition: transform 0.3s;
45-
}
4649
47-
.gallery-item img {
48-
width: 100%;
49-
height: auto;
50-
display: block;
51-
transition: transform 0.3s;
52-
}
50+
.gallery {
51+
display: grid;
52+
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
53+
gap: 10px;
54+
//max-width: 1000px;
55+
background-color: #fff;
56+
box-shadow: 0 0 10px rgba(0,0,0,0.1);
57+
}
5358
54-
.gallery-item:hover img {
55-
transform: scale(1.1);
56-
}
59+
.gallery-item {
60+
position: relative;
61+
overflow: hidden;
62+
background: #f0f0f0;
63+
cursor: pointer;
64+
transition: transform 0.3s;
65+
}
66+
67+
.gallery-item img {
68+
width: 100%;
69+
height: auto;
70+
display: block;
71+
transition: transform 0.3s;
72+
}
73+
74+
.gallery-item:hover img {
75+
transform: scale(1.1);
76+
}
77+
78+
.gallery-item:hover {
79+
transform: scale(1.05);
80+
}
5781
58-
.gallery-item:hover {
59-
transform: scale(1.05);
6082
}
6183
6284
</style>

0 commit comments

Comments
 (0)