2023-10-10 22:07:57 -04:00
|
|
|
<script setup lang="ts">
|
|
|
|
import singleStory from "~/components/listings/singleStory.vue";
|
2023-12-20 17:23:31 -05:00
|
|
|
import { IStory } from "@models/stories";
|
2023-10-10 22:07:57 -04:00
|
|
|
const route = useRoute();
|
|
|
|
let curPage = ref(route.query.page || 1);
|
2023-12-25 20:17:11 -05:00
|
|
|
const props = defineProps<{
|
2024-01-04 20:46:12 -05:00
|
|
|
prefix: string;
|
2023-12-25 20:17:11 -05:00
|
|
|
last?: boolean;
|
|
|
|
}>();
|
2024-01-04 20:46:12 -05:00
|
|
|
let data = (
|
|
|
|
await useApiFetch<any>(props.prefix, {
|
|
|
|
query: {
|
|
|
|
page: curPage.value,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
).data.value;
|
2023-10-10 22:07:57 -04:00
|
|
|
let rdata = ref(data);
|
2024-01-04 20:46:12 -05:00
|
|
|
const loading = ref<boolean>(false);
|
|
|
|
const pagiChange = (page, pageSize) => {
|
|
|
|
loading.value = true;
|
2023-10-10 22:07:57 -04:00
|
|
|
curPage.value = page;
|
2024-01-04 20:46:12 -05:00
|
|
|
useApiFetch(props.prefix, {
|
2023-12-20 17:23:31 -05:00
|
|
|
query: {
|
2024-01-04 20:46:12 -05:00
|
|
|
page,
|
2023-12-20 17:23:31 -05:00
|
|
|
},
|
2024-01-04 20:46:12 -05:00
|
|
|
}).then(({ data }) => {
|
|
|
|
rdata.value = data.value;
|
|
|
|
loading.value = false;
|
|
|
|
navigateTo({
|
|
|
|
path: useRoute().fullPath,
|
|
|
|
query: {
|
|
|
|
page,
|
|
|
|
},
|
|
|
|
});
|
2023-12-20 17:23:31 -05:00
|
|
|
});
|
2023-10-10 22:07:57 -04:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
2023-12-20 17:23:31 -05:00
|
|
|
<div>
|
2024-01-04 20:46:12 -05:00
|
|
|
<a-list v-model:data-source="rdata.stories" item-layout="vertical" v-model:loading="loading">
|
2023-12-20 17:23:31 -05:00
|
|
|
<template #renderItem="{ item }">
|
2024-01-04 20:46:12 -05:00
|
|
|
<single-story :key="item._id" :story="item" :last="last" />
|
2023-12-20 17:23:31 -05:00
|
|
|
</template>
|
|
|
|
</a-list>
|
|
|
|
<a-pagination
|
2024-01-04 20:46:12 -05:00
|
|
|
v-model:disabled="loading"
|
2023-12-20 17:23:31 -05:00
|
|
|
:default-page-size="20"
|
|
|
|
:total="rdata.total"
|
|
|
|
@change="pagiChange"
|
|
|
|
:show-quick-jumper="true"
|
|
|
|
:show-size-changer="false"
|
|
|
|
/>
|
|
|
|
</div>
|
2023-10-10 22:07:57 -04:00
|
|
|
</template>
|
2024-07-09 20:40:24 -04:00
|
|
|
<style>
|
|
|
|
ul.ant-list-items > * + * {
|
2023-10-10 22:07:57 -04:00
|
|
|
margin-top: 1.2em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.ant-pagination {
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
</style>
|