Added thumbnail textarea in quicky and fix content display.
This commit is contained in:
@@ -8,6 +8,7 @@ const client = useClient();
|
|||||||
const title = ref('');
|
const title = ref('');
|
||||||
const message = ref('');
|
const message = ref('');
|
||||||
const files = ref([]);
|
const files = ref([]);
|
||||||
|
const Thumbnail = ref([]);
|
||||||
const externalUrls = ref([]);
|
const externalUrls = ref([]);
|
||||||
|
|
||||||
const creatorProfileStore = useCreatorProfileStore();
|
const creatorProfileStore = useCreatorProfileStore();
|
||||||
@@ -103,6 +104,15 @@ const cancelPost = () => {
|
|||||||
<v-btn icon @click="addUrl" class="mt-2">
|
<v-btn icon @click="addUrl" class="mt-2">
|
||||||
<v-icon>mdi-plus</v-icon>
|
<v-icon>mdi-plus</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
<v-file-input v-model="Thumbnail"
|
||||||
|
label="Thumbnail"
|
||||||
|
class="p-2 custom-file-input"
|
||||||
|
variant="outlined"
|
||||||
|
multiple
|
||||||
|
dropzone
|
||||||
|
prepend-icon=""
|
||||||
|
placeholder="Glissez et déposez des fichiers ici ou cliquez pour sélectionner des fichiers"
|
||||||
|
></v-file-input>
|
||||||
|
|
||||||
<v-file-input v-model="files"
|
<v-file-input v-model="files"
|
||||||
label="Glissez vos images"
|
label="Glissez vos images"
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex h-[calc(100vh-118px)] -mt-2 w-full">
|
<div class="flex h-[calc(100vh-118px)] -mt-2 w-full">
|
||||||
|
|
||||||
<div class="flex-1 flex items-center justify-center bg-neutral-500 max-h-screen relative">
|
<div ref="containerRef" class="flex-1 flex items-center justify-center bg-neutral-500 max-h-screen relative">
|
||||||
|
|
||||||
<div class="absolute inset-0 z-0 bg-cover bg-center blur-lg pointer-events-none"
|
<div class="absolute inset-0 z-0 bg-cover bg-center blur-lg pointer-events-none"
|
||||||
:style="{ backgroundImage: `url(${currentImage})` }"></div>
|
:style="{ backgroundImage: `url(${currentImage})` }"></div>
|
||||||
|
|
||||||
<div class="absolute top-8 left-4 z-20">
|
<div class="absolute top-8 left-4 z-20">
|
||||||
<v-btn @click="goBack" variant="plain"
|
<v-btn @click="goBack" variant="plain" class="rounded-full text-white w-12 h-12 flex items-center justify-center">
|
||||||
class="rounded-full text-white w-12 h-12 flex items-center justify-center">
|
|
||||||
<v-icon class="text-black bg-white rounded-full" size="36">mdi-close</v-icon>
|
<v-icon class="text-black bg-white rounded-full" size="36">mdi-close</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</div>
|
</div>
|
||||||
@@ -19,8 +18,13 @@
|
|||||||
</v-btn>
|
</v-btn>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center justify-center w-full h-full z-10">
|
<div class="flex items-center justify-center w-full h-full z-10 overflow-hidden relative">
|
||||||
<component :is="getComponent(currentImage)" :src="currentImage" class="max-w-full max-h-full object-contain"/>
|
<component
|
||||||
|
:is="getComponent(currentImage)"
|
||||||
|
:src="currentImage"
|
||||||
|
:style="isImage(currentImage) ? imageStyle : {}"
|
||||||
|
:class="isImage(currentImage) ? 'image-content' : 'video-content'"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="multipleImages" class="absolute right-4 top-1/2 transform -translate-y-1/2 z-10">
|
<div v-if="multipleImages" class="absolute right-4 top-1/2 transform -translate-y-1/2 z-10">
|
||||||
@@ -56,17 +60,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {ref, computed, onMounted, watch} from 'vue';
|
import { ref, computed, onMounted, watch, onBeforeUnmount } 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 DonationButton from "@/views/creators/DonationButton.vue";
|
import DonationButton from "@/views/creators/DonationButton.vue";
|
||||||
import YoutubePlayer from '../YoutubePlayer.vue';
|
import YoutubePlayer from '../YoutubePlayer.vue';
|
||||||
import ImageViewer from '../ImageViewer.vue';
|
import ImageViewer from '../ImageViewer.vue';
|
||||||
import {useClient} from "@/plugins/api.js";
|
import { useClient } from "@/plugins/api.js";
|
||||||
import {useRoute} from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import Reaction from "@/views/contents/Reaction.vue";
|
import Reaction from "@/views/contents/Reaction.vue";
|
||||||
import {useMessageStore} from "@/stores/messageStore.js";
|
import { useMessageStore } from "@/stores/messageStore.js";
|
||||||
|
|
||||||
const data = ref(null);
|
const data = ref(null);
|
||||||
const currentImageIndex = ref(0);
|
const currentImageIndex = ref(0);
|
||||||
@@ -87,9 +92,39 @@ const currentImage = computed(() => {
|
|||||||
return '';
|
return '';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const multipleImages = computed(() => data.value?.urls.length > 1);
|
const multipleImages = computed(() => data.value?.urls.length > 1);
|
||||||
|
|
||||||
|
const containerRef = ref(null);
|
||||||
|
const containerWidth = ref(0);
|
||||||
|
const containerHeight = ref(0);
|
||||||
|
|
||||||
|
function updateContainerDimensions() {
|
||||||
|
if (containerRef.value) {
|
||||||
|
containerWidth.value = containerRef.value.offsetWidth;
|
||||||
|
containerHeight.value = containerRef.value.offsetHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
updateContainerDimensions();
|
||||||
|
window.addEventListener('resize', updateContainerDimensions);
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
window.removeEventListener('resize', updateContainerDimensions);
|
||||||
|
});
|
||||||
|
|
||||||
|
const imageStyle = computed(() => {
|
||||||
|
return {
|
||||||
|
maxWidth: `${containerWidth.value}px`,
|
||||||
|
maxHeight: `${containerHeight.value}px`,
|
||||||
|
objectFit: 'contain',
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
function isImage(url) {
|
||||||
|
return url.match(/\.(jpeg|jpg|gif|png)$/);
|
||||||
|
}
|
||||||
|
|
||||||
function getComponent(url) {
|
function getComponent(url) {
|
||||||
if (url.includes('youtube.com') || url.includes('youtu.be')) {
|
if (url.includes('youtube.com') || url.includes('youtu.be')) {
|
||||||
@@ -100,7 +135,6 @@ function getComponent(url) {
|
|||||||
return 'div';
|
return 'div';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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}`);
|
||||||
@@ -110,38 +144,32 @@ const fetchContentData = async (contentId) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function goBack() {
|
function goBack() {
|
||||||
window.history.go(-1);
|
window.history.go(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function nextImage() {
|
function nextImage() {
|
||||||
if (data.value?.urls.length > 0) {
|
if (data.value?.urls.length > 0) {
|
||||||
currentImageIndex.value = (currentImageIndex.value + 1) % data.value.urls.length;
|
currentImageIndex.value = (currentImageIndex.value + 1) % data.value.urls.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function previousImage() {
|
function previousImage() {
|
||||||
if (data.value?.urls.length > 0) {
|
if (data.value?.urls.length > 0) {
|
||||||
currentImageIndex.value = (currentImageIndex.value - 1 + data.value.urls.length) % data.value.urls.length;
|
currentImageIndex.value = (currentImageIndex.value - 1 + data.value.urls.length) % data.value.urls.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function toggleComments() {
|
function toggleComments() {
|
||||||
messagesVisible.value = !messagesVisible.value;
|
messagesVisible.value = !messagesVisible.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function addMessage(newMessage) {
|
function addMessage(newMessage) {
|
||||||
messages.value.unshift(newMessage);
|
messages.value.unshift(newMessage);
|
||||||
messagesVisible.value = true;
|
messagesVisible.value = true;
|
||||||
messageCount.value++;
|
messageCount.value++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await fetchContentData(contentId.value);
|
await fetchContentData(contentId.value);
|
||||||
messageCount.value = await messageStore.fetchMessageCount(contentId.value);
|
messageCount.value = await messageStore.fetchMessageCount(contentId.value);
|
||||||
@@ -153,9 +181,9 @@ watch(contentId, async (newContentId) => {
|
|||||||
messageCount.value = await messageStore.fetchMessageCount(newContentId);
|
messageCount.value = await messageStore.fetchMessageCount(newContentId);
|
||||||
messages.value = await messageStore.fetchMessages(newContentId);
|
messages.value = await messageStore.fetchMessages(newContentId);
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.fixed-width {
|
.fixed-width {
|
||||||
width: 400px;
|
width: 400px;
|
||||||
@@ -172,4 +200,18 @@ watch(contentId, async (newContentId) => {
|
|||||||
.v-btn .v-icon {
|
.v-btn .v-icon {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.image-content {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.video-content {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user