Remove news
This commit is contained in:
@@ -23,7 +23,6 @@ import ForYouPage from "@/views/ForYouPage.vue";
|
|||||||
import CreatorLayout from "@/views/creators/CreatorLayout.vue";
|
import CreatorLayout from "@/views/creators/CreatorLayout.vue";
|
||||||
import ContentPage from "@/views/contents/ContentPage.vue";
|
import ContentPage from "@/views/contents/ContentPage.vue";
|
||||||
import CreatorContent from "@/views/creators/CreatorContent.vue";
|
import CreatorContent from "@/views/creators/CreatorContent.vue";
|
||||||
import CreatorNews from "@/views/creators/CreatorNews.vue";
|
|
||||||
import CreatorHome from "@/views/creators/CreatorHome.vue";
|
import CreatorHome from "@/views/creators/CreatorHome.vue";
|
||||||
import CTA01 from "@/views/CTA01.vue";
|
import CTA01 from "@/views/CTA01.vue";
|
||||||
|
|
||||||
@@ -55,10 +54,6 @@ const routes = [
|
|||||||
path: '',
|
path: '',
|
||||||
component: CreatorHome,
|
component: CreatorHome,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: 'news',
|
|
||||||
component: CreatorNews,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: 'content',
|
path: 'content',
|
||||||
component: CreatorContent
|
component: CreatorContent
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
<template>
|
|
||||||
|
|
||||||
<div v-if="brandingStore.value.loading">
|
|
||||||
<v-progress-linear indeterminate></v-progress-linear>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-else>
|
|
||||||
<div class="w-full h-full pr-4">
|
|
||||||
<news-list :creator-id="brandingStore.value.id"
|
|
||||||
:news="news"
|
|
||||||
></news-list>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script async setup>
|
|
||||||
import {ref} from 'vue';
|
|
||||||
import NewsList from "@/views/news/NewsList.vue";
|
|
||||||
import {useBrandingStore} from "@/stores/brandingStore.js";
|
|
||||||
|
|
||||||
const brandingStore = useBrandingStore()
|
|
||||||
|
|
||||||
const news = ref([])
|
|
||||||
function newsPosted(content) {
|
|
||||||
news.value.unshift(content)
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
@@ -126,10 +126,6 @@
|
|||||||
:to="`/@${brandingStore.value.name}`">
|
:to="`/@${brandingStore.value.name}`">
|
||||||
Présentation
|
Présentation
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<RouterLink class="nav-button text-white hover:bg-gray-700"
|
|
||||||
:to="`/@${brandingStore.value.name}/news`">
|
|
||||||
Actualité
|
|
||||||
</RouterLink>
|
|
||||||
<RouterLink class="nav-button text-white hover:bg-gray-700"
|
<RouterLink class="nav-button text-white hover:bg-gray-700"
|
||||||
:to="`/@${brandingStore.value.name}/content`">
|
:to="`/@${brandingStore.value.name}/content`">
|
||||||
Exclusivité
|
Exclusivité
|
||||||
|
|||||||
@@ -1,122 +0,0 @@
|
|||||||
<template>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
|
|
||||||
<v-infinite-scroll :items="contents"
|
|
||||||
:onLoad="fetchContents">
|
|
||||||
|
|
||||||
<!-- TODO: the -mt-4 is necessary because the v-infinite-scroll has some 'top' panel offsetting the list -->
|
|
||||||
<div class="flex flex-column gap-4 -mt-4">
|
|
||||||
<template v-for="content in contents" :key="content.id">
|
|
||||||
<component
|
|
||||||
:is="isSmallScreen ? ContentCardSm : ContentCardNormal"
|
|
||||||
:content="content"
|
|
||||||
@content-deleted="onContentDeleted"
|
|
||||||
></component>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<template v-slot:empty>
|
|
||||||
Il n'y a pas plus de contenus
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot:error>
|
|
||||||
<v-alert type="error">{{ errorMessage }}</v-alert>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
</v-infinite-scroll>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {useClient} from '@/plugins/api.js';
|
|
||||||
import {onBeforeUnmount, onMounted, ref, watch} from 'vue';
|
|
||||||
import ContentCardNormal from "@/views/contents/contentcards/NContentCard.vue";
|
|
||||||
import ContentCardSm from "@/views/contents/contentcards/SmContentCard.vue";
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
creatorId: {
|
|
||||||
type: String,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
news: {
|
|
||||||
type: Array,
|
|
||||||
default: () => [],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const client = useClient()
|
|
||||||
const contents = ref(props.news)
|
|
||||||
const errorMessage = ref()
|
|
||||||
let last_id = null
|
|
||||||
|
|
||||||
const isSmallScreen = ref(false);
|
|
||||||
|
|
||||||
const updateScreenSize = () => {
|
|
||||||
isSmallScreen.value = window.matchMedia('(max-width: 600px)').matches;
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
updateScreenSize();
|
|
||||||
window.addEventListener('resize', updateScreenSize);
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
window.removeEventListener('resize', updateScreenSize);
|
|
||||||
});
|
|
||||||
|
|
||||||
async function onContentDeleted(contentId) {
|
|
||||||
contents.value = contents.value.filter(c => c.id !== contentId)
|
|
||||||
}
|
|
||||||
|
|
||||||
const creatorIdWatcher = watch(
|
|
||||||
() => props.creatorId,
|
|
||||||
(newCreatorId) => {
|
|
||||||
if (newCreatorId) {
|
|
||||||
contents.value = []
|
|
||||||
last_id = null
|
|
||||||
fetchContents({
|
|
||||||
done: () => {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
async function fetchContents({done, page_size = 10}) {
|
|
||||||
if (props.creatorId == null) return
|
|
||||||
|
|
||||||
try {
|
|
||||||
let uri = `/api/contents/creator/${props.creatorId}?page_size=${page_size}`
|
|
||||||
if (last_id !== null) uri = uri + `&last_id=${last_id}`
|
|
||||||
|
|
||||||
const response = await client.get(uri)
|
|
||||||
|
|
||||||
if (response.status >= 200 && response.status < 300) {
|
|
||||||
|
|
||||||
const contentCount = response.data.length
|
|
||||||
|
|
||||||
if (contentCount > 0) {
|
|
||||||
contents.value.push(...response.data)
|
|
||||||
const [last_content] = response.data.slice(-1)
|
|
||||||
last_id = last_content.id
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contentCount < page_size)
|
|
||||||
done('empty')
|
|
||||||
else
|
|
||||||
done('ok')
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to fetch posts", error);
|
|
||||||
errorMessage.value = error.message || "Failed to fetch contents";
|
|
||||||
done('error')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
Reference in New Issue
Block a user