2
2
<div class =" square-container" >
3
3
<el-input
4
4
v-model =" searchText"
5
- style =" width : 100% ;margin-bottom : 20px ; "
5
+ style =" width : 100% ; margin-bottom : 20px "
6
6
size =" large"
7
7
placeholder =" 请输入要搜索的内容"
8
8
:suffix-icon =" Search"
9
9
@keyup.enter =" handleSearch"
10
10
/>
11
11
<div class =" gallery" >
12
- <div v-for =" item in publicList" :key =" item" class =" gallery-item" >
13
- <img :src =" item.picUrl" class =" img" />
12
+ <div v-for =" item in publicList" :key =" item.id " class =" gallery-item" >
13
+ <img :src =" item.picUrl" class =" img" />
14
14
</div >
15
15
</div >
16
16
</div >
17
17
</template >
18
18
<script setup lang="ts">
19
- import { ImageApi , ImageVO , ImageMidjourneyButtonsVO } from ' @/api/ai/image'
20
- import {Search } from " @element-plus/icons-vue" ;
19
+ import { ImageApi , ImageVO } from ' @/api/ai/image'
20
+ import { Search } from ' @element-plus/icons-vue'
21
21
22
22
/** 属性 */
23
+ // TODO @fan:queryParams 里面搞分页哈。
23
24
const pageNo = ref <number >(1 )
24
25
const pageSize = ref <number >(20 )
25
26
const publicList = ref <ImageVO []>([])
26
27
const searchText = ref <string >(' ' )
27
28
28
29
/** 获取数据 */
29
30
const getListData = async () => {
30
- const res = await ImageApi .getImagePagePublic ({pageNo: pageNo .value , pageSize: pageSize .value , prompt: searchText .value });
31
- publicList .value = res .list as ImageVO [];
31
+ const res = await ImageApi .getImagePagePublic ({
32
+ pageNo: pageNo .value ,
33
+ pageSize: pageSize .value ,
34
+ prompt: searchText .value
35
+ })
36
+ publicList .value = res .list as ImageVO []
32
37
}
33
38
34
39
/** 搜索 */
35
40
const handleSearch = async () => {
36
- await getListData ();
41
+ await getListData ()
37
42
}
38
43
39
44
onMounted (async () => {
40
45
await getListData ()
41
46
})
42
47
</script >
43
48
<style scoped lang="scss">
44
-
45
49
.square-container {
46
50
background-color : #fff ;
47
51
padding : 20px ;
48
52
49
-
50
53
.gallery {
51
54
display : grid ;
52
55
grid-template-columns : repeat (auto-fill , minmax (200px , 1fr ));
53
56
gap : 10px ;
54
57
// max-width: 1000px;
55
58
background-color : #fff ;
56
- box-shadow : 0 0 10px rgba (0 ,0 , 0 , 0.1 );
59
+ box-shadow : 0 0 10px rgba (0 , 0 , 0 , 0.1 );
57
60
}
58
61
59
62
.gallery-item {
@@ -78,7 +81,5 @@ onMounted(async () => {
78
81
.gallery-item :hover {
79
82
transform : scale (1.05 );
80
83
}
81
-
82
84
}
83
-
84
85
</style >
0 commit comments