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<{
|
|
|
|
prefix?: string;
|
|
|
|
items?: IStory[];
|
|
|
|
last?: boolean;
|
|
|
|
}>();
|
2023-10-10 22:07:57 -04:00
|
|
|
let data;
|
|
|
|
if (!props.prefix) {
|
|
|
|
data = props.items;
|
|
|
|
} else if (!props.items) {
|
|
|
|
data = (
|
|
|
|
await useApiFetch<any>(`${props.prefix}`, {
|
|
|
|
query: {
|
|
|
|
page: curPage,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
).data;
|
|
|
|
}
|
|
|
|
let rdata = ref(data);
|
|
|
|
const pagiChange = async (page, pageSize) => {
|
|
|
|
curPage.value = page;
|
|
|
|
// await navigateTo({
|
|
|
|
// path: useRoute().fullPath,
|
|
|
|
// query: {
|
|
|
|
// page
|
|
|
|
// }
|
|
|
|
// })
|
2023-12-20 17:23:31 -05:00
|
|
|
let { data: data } = await useApiFetch(`${props.prefix}`, {
|
|
|
|
query: {
|
|
|
|
page: curPage,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
rdata.value = data.value;
|
2023-10-10 22:07:57 -04:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<template>
|
2023-12-20 17:23:31 -05:00
|
|
|
<div>
|
|
|
|
<a-list :data-source="rdata.stories" item-layout="vertical">
|
|
|
|
<template #renderItem="{ item }">
|
|
|
|
<!-- {{ item.title }} -->
|
2023-12-25 20:17:11 -05:00
|
|
|
<single-story :story="item" :last="last" />
|
2023-12-20 17:23:31 -05:00
|
|
|
</template>
|
|
|
|
</a-list>
|
|
|
|
<a-pagination
|
|
|
|
:default-page-size="20"
|
|
|
|
:total="rdata.total"
|
|
|
|
:default-current="curPage as number"
|
|
|
|
@change="pagiChange"
|
|
|
|
:show-quick-jumper="true"
|
|
|
|
:show-size-changer="false"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<!-- {
|
2023-10-10 22:07:57 -04:00
|
|
|
defaultPageSize: 20,
|
|
|
|
total: rdata.total,
|
|
|
|
defaultCurrent: curPage as number,
|
2023-12-20 17:23:31 -05:00
|
|
|
onChange: pagiChange,
|
|
|
|
// hideOnSinglePage: true,
|
2023-10-10 22:07:57 -04:00
|
|
|
showSizeChanger: false,
|
2023-12-20 17:23:31 -05:00
|
|
|
}-->
|
2023-10-10 22:07:57 -04:00
|
|
|
</template>
|
|
|
|
<style scoped>
|
|
|
|
.ant-list-items > * + * {
|
|
|
|
margin-top: 1.2em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.ant-pagination {
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
</style>
|