Update UI - You can watch the image in fullscreen in content page
This commit is contained in:
@@ -45,13 +45,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
|
|
||||||
<router-link :to="'content/' + props?.content?.id">
|
<v-carousel
|
||||||
</router-link>
|
hide-delimiters
|
||||||
<v-carousel hide-delimiters v-if="hasUrls" :show-arrows="props.content.urls.length > 1" :show-indicators="props.content.urls.length > 1">
|
v-if="hasUrls"
|
||||||
|
:show-arrows="props.content.urls.length > 1"
|
||||||
|
:show-indicators="props.content.urls.length > 1"
|
||||||
|
>
|
||||||
<v-carousel-item
|
<v-carousel-item
|
||||||
v-for="url in props.content.urls"
|
v-for="url in props.content.urls"
|
||||||
:key="url"
|
:key="url"
|
||||||
class="image-container"
|
class="image-container"
|
||||||
|
@click="redirectToContent"
|
||||||
>
|
>
|
||||||
<component :is="getComponent(url)" :src="url"></component>
|
<component :is="getComponent(url)" :src="url"></component>
|
||||||
</v-carousel-item>
|
</v-carousel-item>
|
||||||
@@ -70,8 +74,7 @@
|
|||||||
:class="{'comment-active': hasComments}"
|
:class="{'comment-active': hasComments}"
|
||||||
variant="plain"
|
variant="plain"
|
||||||
icon
|
icon
|
||||||
@click="toggleComments"
|
@click="toggleComments">
|
||||||
>
|
|
||||||
<v-icon>mdi-comment-outline</v-icon>
|
<v-icon>mdi-comment-outline</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</div>
|
</div>
|
||||||
@@ -89,7 +92,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref, onMounted } from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import { time_ago } from "@/internal_time_ago.js";
|
import { time_ago } from "@/internal_time_ago.js";
|
||||||
import MessageList from "@/views/messages/MessageList.vue";
|
import MessageList from "@/views/messages/MessageList.vue";
|
||||||
import PostMessage from "@/views/messages/PostMessage.vue";
|
import PostMessage from "@/views/messages/PostMessage.vue";
|
||||||
@@ -112,6 +115,7 @@ const hasComments = computed(() => messages.value.length > 0);
|
|||||||
|
|
||||||
function addMessage(newMessage) {
|
function addMessage(newMessage) {
|
||||||
messages.value.unshift(newMessage);
|
messages.value.unshift(newMessage);
|
||||||
|
commentsVisible.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleComments() {
|
function toggleComments() {
|
||||||
@@ -145,6 +149,10 @@ function deleteContent() {
|
|||||||
function reportContent() {
|
function reportContent() {
|
||||||
console.log('Reporter le contenu');
|
console.log('Reporter le contenu');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function redirectToContent() {
|
||||||
|
window.location.href = `/content/${props.content.id}`;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -153,6 +161,7 @@ function reportContent() {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.image-container img {
|
.image-container img {
|
||||||
|
|||||||
@@ -1,7 +1,30 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div class="flex h-screen">
|
||||||
|
|
||||||
<div class="flex flex-column w-full">
|
<!-- 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>
|
||||||
|
|
||||||
|
<!-- Content details section (right) -->
|
||||||
|
<div class="fixed-width border-l-2 p-6 bg-white overflow-y-auto h-full">
|
||||||
|
|
||||||
|
<!-- Content details -->
|
||||||
<div class="border-b-2 p-6 font-sans space-y-2">
|
<div class="border-b-2 p-6 font-sans space-y-2">
|
||||||
<div v-if="data && data.uri">
|
<div v-if="data && data.uri">
|
||||||
Uri: {{ data?.uri }}
|
Uri: {{ data?.uri }}
|
||||||
@@ -20,32 +43,34 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="border-b-2 p-6">
|
<!-- Comments Section -->
|
||||||
<PostMessage :content-id="contentId">
|
|
||||||
</PostMessage>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="border-b-2 p-6">
|
<div class="border-b-2 p-6">
|
||||||
<h2 class="font-sans font-semibold">Commentaires</h2>
|
<h2 class="font-sans font-semibold">Commentaires</h2>
|
||||||
<MessageList :content-id="contentId">
|
<MessageList :content-id="contentId"></MessageList>
|
||||||
</MessageList>
|
</div>
|
||||||
|
|
||||||
|
<!-- Post a new message -->
|
||||||
|
<div class="border-b-2 p-6">
|
||||||
|
<PostMessage :content-id="contentId"></PostMessage>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup async>
|
<script setup>
|
||||||
|
import { ref, computed, onMounted, watch } from 'vue';
|
||||||
import PostMessage from "@/views/messages/PostMessage.vue";
|
import PostMessage from "@/views/messages/PostMessage.vue";
|
||||||
import MessageList from "@/views/messages/MessageList.vue";
|
import MessageList from "@/views/messages/MessageList.vue";
|
||||||
import {useClient} from "@/plugins/api.js";
|
import YoutubePlayer from './YoutubePlayer.vue';
|
||||||
import {onMounted, watch, ref, computed} from 'vue';
|
import ImageViewer from './ImageViewer.vue';
|
||||||
import {useRoute} from 'vue-router';
|
import { useClient } from "@/plugins/api.js";
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
const data = ref()
|
const data = ref();
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute();
|
||||||
const client = useClient()
|
const client = useClient();
|
||||||
|
|
||||||
const contentId = computed(() => {
|
const contentId = computed(() => {
|
||||||
return route.params.contentId;
|
return route.params.contentId;
|
||||||
@@ -53,12 +78,12 @@ const contentId = computed(() => {
|
|||||||
|
|
||||||
const fetchContentData = async (contentId) => {
|
const fetchContentData = async (contentId) => {
|
||||||
try {
|
try {
|
||||||
const response = await client.get(`/api/contents/${contentId}`)
|
const response = await client.get(`/api/contents/${contentId}`);
|
||||||
data.value = response.data
|
data.value = response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error fetching content: ${error}`)
|
console.error(`Error fetching content: ${error}`);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fetchContentData(contentId.value);
|
fetchContentData(contentId.value);
|
||||||
@@ -68,7 +93,34 @@ watch(contentId, (newContentId) => {
|
|||||||
fetchContentData(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>
|
</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