Update UI - You can watch the image in fullscreen in content page
This commit is contained in:
@@ -1,51 +1,76 @@
|
||||
<template>
|
||||
<div class="flex h-screen">
|
||||
|
||||
<div class="flex flex-column w-full">
|
||||
|
||||
<div class="border-b-2 p-6 font-sans space-y-2">
|
||||
<div v-if="data && data.uri">
|
||||
Uri: {{ data?.uri }}
|
||||
</div>
|
||||
<div v-if="data && data.title" class="font-semibold">
|
||||
Title: {{ data?.title }}
|
||||
</div>
|
||||
<div v-if="data && data.description">
|
||||
Description: {{ data?.description }}
|
||||
</div>
|
||||
<div v-if="data && data.createdAt">
|
||||
Date: {{ data?.createdAt }}
|
||||
</div>
|
||||
<div v-if="data && data.createdBy">
|
||||
Creator: {{ data?.createdBy }}
|
||||
</div>
|
||||
<!-- Carousel section (left) -->
|
||||
<div class="flex-1 flex items-center justify-center bg-neutral-500">
|
||||
<v-carousel
|
||||
v-if="data?.urls && data.urls.length > 0"
|
||||
hide-delimiters
|
||||
:show-arrows="data.urls.length > 1"
|
||||
:show-indicators="data.urls.length > 1"
|
||||
class="w-full h-full flex items-center justify-center"
|
||||
|
||||
>
|
||||
<v-carousel-item
|
||||
v-for="url in data.urls"
|
||||
:key="url"
|
||||
class="flex items-center justify-center"
|
||||
>
|
||||
<component :is="getComponent(url)" :src="url" class="max-h-full max-w-full object-contain"></component>
|
||||
</v-carousel-item>
|
||||
</v-carousel>
|
||||
</div>
|
||||
|
||||
<div class="border-b-2 p-6">
|
||||
<PostMessage :content-id="contentId">
|
||||
</PostMessage>
|
||||
</div>
|
||||
<!-- Content details section (right) -->
|
||||
<div class="fixed-width border-l-2 p-6 bg-white overflow-y-auto h-full">
|
||||
|
||||
<div class="border-b-2 p-6">
|
||||
<h2 class="font-sans font-semibold">Commentaires</h2>
|
||||
<MessageList :content-id="contentId">
|
||||
</MessageList>
|
||||
</div>
|
||||
<!-- Content details -->
|
||||
<div class="border-b-2 p-6 font-sans space-y-2">
|
||||
<div v-if="data && data.uri">
|
||||
Uri: {{ data?.uri }}
|
||||
</div>
|
||||
<div v-if="data && data.title" class="font-semibold">
|
||||
Title: {{ data?.title }}
|
||||
</div>
|
||||
<div v-if="data && data.description">
|
||||
Description: {{ data?.description }}
|
||||
</div>
|
||||
<div v-if="data && data.createdAt">
|
||||
Date: {{ data?.createdAt }}
|
||||
</div>
|
||||
<div v-if="data && data.createdBy">
|
||||
Creator: {{ data?.createdBy }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Comments Section -->
|
||||
<div class="border-b-2 p-6">
|
||||
<h2 class="font-sans font-semibold">Commentaires</h2>
|
||||
<MessageList :content-id="contentId"></MessageList>
|
||||
</div>
|
||||
|
||||
<!-- Post a new message -->
|
||||
<div class="border-b-2 p-6">
|
||||
<PostMessage :content-id="contentId"></PostMessage>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup async>
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, watch } from 'vue';
|
||||
import PostMessage from "@/views/messages/PostMessage.vue";
|
||||
import MessageList from "@/views/messages/MessageList.vue";
|
||||
import {useClient} from "@/plugins/api.js";
|
||||
import {onMounted, watch, ref, computed} from 'vue';
|
||||
import {useRoute} from 'vue-router';
|
||||
import YoutubePlayer from './YoutubePlayer.vue';
|
||||
import ImageViewer from './ImageViewer.vue';
|
||||
import { useClient } from "@/plugins/api.js";
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const data = ref()
|
||||
const data = ref();
|
||||
|
||||
const route = useRoute()
|
||||
const client = useClient()
|
||||
const route = useRoute();
|
||||
const client = useClient();
|
||||
|
||||
const contentId = computed(() => {
|
||||
return route.params.contentId;
|
||||
@@ -53,12 +78,12 @@ const contentId = computed(() => {
|
||||
|
||||
const fetchContentData = async (contentId) => {
|
||||
try {
|
||||
const response = await client.get(`/api/contents/${contentId}`)
|
||||
data.value = response.data
|
||||
const response = await client.get(`/api/contents/${contentId}`);
|
||||
data.value = response.data;
|
||||
} catch (error) {
|
||||
console.error(`Error fetching content: ${error}`)
|
||||
console.error(`Error fetching content: ${error}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
fetchContentData(contentId.value);
|
||||
@@ -68,7 +93,34 @@ watch(contentId, (newContentId) => {
|
||||
fetchContentData(newContentId);
|
||||
});
|
||||
|
||||
function getComponent(url) {
|
||||
if (url.includes('youtube.com') || url.includes('youtu.be')) {
|
||||
return YoutubePlayer;
|
||||
} else if (url.match(/\.(jpeg|jpg|gif|png)$/)) {
|
||||
return ImageViewer;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
<style scoped>
|
||||
.fixed-width {
|
||||
width: 400px;
|
||||
}
|
||||
|
||||
.custom-border {
|
||||
border-color: #EAEBEC;
|
||||
}
|
||||
|
||||
.v-carousel-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.v-carousel-item img {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user