Full feature of posts preview

This commit is contained in:
LittleSheep 2024-08-10 16:09:17 +08:00
parent c25640b673
commit ecc17c5cf5
3 changed files with 57 additions and 13 deletions

View File

@ -0,0 +1,51 @@
<template>
<v-carousel
hide-delimiter-background
hide-delimiters
:progress="attachments.length > 1"
:show-arrows="attachments.length > 1 ? 'hover' : false"
height="auto"
>
<v-carousel-item v-for="item in metadata" class="fill-height">
<v-img v-if="item.mimetype.split('/')[0] == 'image'" :src="getAttachmentUrl(item.id)" class="fill-height" cover />
<video v-if="item.mimetype.split('/')[0] == 'video'" :src="getAttachmentUrl(item.id)" class="fill-height"
controls />
<v-sheet v-else color="rgba(0, 0, 0, .4)" height="calc(100% + 24px)" class="p-5">
<v-row class="fill-height" align="center" justify="center">
<v-col class="text-center">
<h1 class="text-xl font-bold text-white">
{{ item.alt }}
</h1>
<p class="text-md text-white">{{ item.mimetype }}</p>
<p class="text-sm text-white mt-3">Unable to preview, you can open it via other ways.</p>
<div class="flex justify-center mt-3">
<v-btn
variant="text"
color="white"
prepend-icon="mdi-launch"
text="Open in browser"
:href="getAttachmentUrl(item.id)"
target="_blank"
/>
</div>
</v-col>
</v-row>
</v-sheet>
</v-carousel-item>
</v-carousel>
</template>
<script setup lang="ts">
const props = defineProps<{ attachments: number[] }>()
const config = useRuntimeConfig()
const { data } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/files/attachments?take=${props.attachments.length}&id=${props.attachments.join(",")}`)
const metadata = computed(() => data.value.data)
function getAttachmentUrl(id: number) {
return `${config.public.solarNetworkApi}/cgi/files/attachments/${id}`
}
</script>

View File

@ -1,7 +1,7 @@
<template>
<v-carousel class="carousel-section" show-arrows="hover" cycle hide-delimiters>
<v-carousel-item v-for="(item, i) in props.products" :key="i" :src="item?.thumbnail" cover>
<v-sheet color="rgba(0, 0, 0, .4)" height="calc(100% + 24px)">
<v-sheet color="rgba(0, 0, 0, .4)" height="calc(100% + 24px)" class="p-5">
<v-row class="fill-height" align="center" justify="center">
<v-col class="text-center">
<h1 class="text-4xl font-bold text-white" :class="item?.archived ? 'line-through' : null">

View File

@ -15,14 +15,7 @@
</article>
<v-card v-if="post.body?.attachments?.length > 0" class="mb-5">
<v-carousel hide-delimiter-background hide-delimiters progress show-arrows="hover">
<v-carousel-item
v-for="attachment in post.body?.attachments"
:src="getAttachmentUrl(attachment)"
:aspect-ratio="16 / 9"
cover
/>
</v-carousel>
<attachment-carousel :attachments="post.body?.attachments" />
</v-card>
<div class="mb-3 text-sm flex flex-col">
@ -40,6 +33,10 @@
</span>
</div>
<div v-if="post.tags?.length > 0" class="text-xs text-grey flex flex-row gap-1 mb-3">
<span v-for="tag in post.tags">#{{ tag.alias }}</span>
</div>
<div class="text-xs text-grey flex flex-col">
<span>Solar Network Post Web Preview</span>
<span>To get full view of this post, open it on <a class="underline" :href="externalOpenLink">Solian</a></span>
@ -69,10 +66,6 @@ useHead({
})
const externalOpenLink = computed(() => `${config.public.solianUrl}/posts/view/${route.params.id}`)
function getAttachmentUrl(id: number) {
return `${config.public.solarNetworkApi}/cgi/files/attachments/${id}`
}
</script>
<style scoped>