2024-08-16 16:43:08 +00:00
|
|
|
<template>
|
|
|
|
<v-infinite-scroll :items="posts" :onLoad="loadPost">
|
|
|
|
<template v-for="item in posts" :key="item">
|
|
|
|
<post-item :post="item" no-clickable-attachment />
|
|
|
|
</template>
|
|
|
|
</v-infinite-scroll>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2024-08-18 16:44:35 +00:00
|
|
|
const props = defineProps<{ author?: string, tag?: string, category?: string, realm?: string }>()
|
2024-08-16 16:43:08 +00:00
|
|
|
|
|
|
|
const config = useRuntimeConfig()
|
|
|
|
|
|
|
|
const posts = ref<any[]>([])
|
|
|
|
|
|
|
|
async function loadPost({ done }: any) {
|
|
|
|
const searchQueries = new URLSearchParams({
|
|
|
|
take: (10).toString(),
|
|
|
|
offset: posts.value.length.toString(),
|
|
|
|
})
|
|
|
|
|
2024-12-08 07:36:03 +00:00
|
|
|
if (props.publisher) {
|
|
|
|
searchQueries.set("author", props.publisher)
|
2024-08-16 16:43:08 +00:00
|
|
|
}
|
2024-08-18 16:44:35 +00:00
|
|
|
if (props.realm) {
|
|
|
|
searchQueries.set("realm", props.realm)
|
2024-08-16 16:43:08 +00:00
|
|
|
}
|
|
|
|
|
2024-08-16 16:51:09 +00:00
|
|
|
if (props.tag) {
|
|
|
|
searchQueries.set("tag", props.tag)
|
|
|
|
}
|
|
|
|
if (props.category) {
|
|
|
|
searchQueries.set("category", props.category)
|
|
|
|
}
|
|
|
|
|
2024-08-17 15:56:03 +00:00
|
|
|
const res = await fetch(`${config.public.solarNetworkApi}/cgi/co/posts?` + searchQueries)
|
2024-08-16 16:43:08 +00:00
|
|
|
const result = await res.json()
|
|
|
|
|
|
|
|
if (result.data.length > 0) {
|
|
|
|
posts.value.push(...result.data)
|
|
|
|
done("ok")
|
|
|
|
} else {
|
|
|
|
done("empty")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|