image-dynamics.vue
1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<script setup lang="ts">
import { ImagePreviewGroup, Grid, GridItem, Image, Pagination } from '@arco-design/web-vue';
import { onMounted, ref } from 'vue';
import usePagination from '@/hooks/pagination';
import useProjectApi from '@/api/project';
const props = defineProps<{ projectKey: number }>();
const { pagination, setPage, setTotal } = usePagination({ pageSize: 12 });
const source = ref([]);
const onQuery = () =>
useProjectApi
.dynamics(props.projectKey, {
type: 'image',
page: pagination.value.current,
pageSize: pagination.value.pageSize,
setSort: '-is_top',
})
.then(({ data, meta }) => {
source.value = data as [];
setPage(meta.current);
setTotal(meta.total);
});
onMounted(() => onQuery());
</script>
<template>
<ImagePreviewGroup>
<Grid :cols="6" :col-gap="12" :row-gap="16">
<GridItem v-for="item in source" :key="item.id">
<Image
:src="`${item.properties.url}?x-oss-process=image/format,webp`"
:width="120"
:height="120"
fit="scale-down"
:show-loader="true"
/>
</GridItem>
</Grid>
</ImagePreviewGroup>
<Pagination
size="mini"
style="justify-content: flex-end; margin-top: 10px"
:current="pagination.current"
:total="pagination.total"
:page-size="pagination.pageSize"
:hide-on-single-page="true"
@change="(current:number) => setPage(current) && onQuery()"
/>
</template>
<style scoped lang="less"></style>