✨ Basic Solar Network product page
This commit is contained in:
@ -27,9 +27,9 @@
|
||||
<div class="flex flex-col" v-if="attachment?.metadata?.ratio">
|
||||
<span class="text-xs font-bold">Aspect Ratio</span>
|
||||
<span>
|
||||
{{ attachment?.metadata?.width }}x{{ attachment?.metadata?.height }}
|
||||
{{ attachment?.metadata?.ratio.toFixed(2) }}
|
||||
</span>
|
||||
{{ attachment?.metadata?.width }}x{{ attachment?.metadata?.height }}
|
||||
{{ attachment?.metadata?.ratio.toFixed(2) }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-col" v-if="attachment?.mimetype">
|
||||
<span class="text-xs font-bold">Mimetype</span>
|
||||
@ -44,13 +44,19 @@
|
||||
|
||||
<div class="text-xs text-grey flex flex-col mx-[2.5ch]">
|
||||
<span>Solar Network Attachment Web Preview</span>
|
||||
<span>Powered by <a class="underline" target="_blank" href="https://git.solsynth.dev/Hydrogen/Paperclip">Hydrogen.Paperclip</a></span>
|
||||
<span
|
||||
>Powered by
|
||||
<a class="underline" target="_blank" href="https://git.solsynth.dev/Hydrogen/Paperclip"
|
||||
>Hydrogen.Paperclip</a
|
||||
></span
|
||||
>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { formatBytes } from "~/utils/format"
|
||||
import { useDisplay } from "vuetify"
|
||||
|
||||
const route = useRoute()
|
||||
@ -61,7 +67,9 @@ const firstVideo = ref<string | null>()
|
||||
|
||||
const isMediumScreen = useDisplay().mdAndUp
|
||||
|
||||
const { data: attachment } = await useFetch<any>(`${config.public.solarNetworkApi}/cgi/uc/attachments/${route.params.id}/meta`)
|
||||
const { data: attachment } = await useFetch<any>(
|
||||
`${config.public.solarNetworkApi}/cgi/uc/attachments/${route.params.id}/meta`,
|
||||
)
|
||||
|
||||
definePageMeta({
|
||||
layout: "minimal",
|
||||
@ -76,15 +84,19 @@ if (!attachment.value) {
|
||||
|
||||
const title = computed(() => `Attachment ${attachment.value?.id}`)
|
||||
|
||||
watch(attachment, (value) => {
|
||||
if (value.mimetype.split("/")[0] == "image") {
|
||||
firstImage.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${value.id}`
|
||||
}
|
||||
watch(
|
||||
attachment,
|
||||
(value) => {
|
||||
if (value.mimetype.split("/")[0] == "image") {
|
||||
firstImage.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${value.id}`
|
||||
}
|
||||
|
||||
if (value.mimetype.split("/")[0] == "video") {
|
||||
firstVideo.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${value.id}`
|
||||
}
|
||||
}, { immediate: true, deep: true })
|
||||
if (value.mimetype.split("/")[0] == "video") {
|
||||
firstVideo.value = `${config.public.solarNetworkApi}/cgi/uc/attachments/${value.id}`
|
||||
}
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
)
|
||||
|
||||
useHead({
|
||||
title: title.value,
|
||||
@ -106,16 +118,4 @@ useSeoMeta({
|
||||
publisher: "Solar Network",
|
||||
ogSiteName: "Solsynth Capital",
|
||||
})
|
||||
|
||||
function formatBytes(bytes: number, decimals = 2) {
|
||||
if (!+bytes) return "0 Bytes"
|
||||
|
||||
const k = 1024
|
||||
const dm = decimals < 0 ? 0 : decimals
|
||||
const sizes = ["Bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||
|
||||
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`
|
||||
}
|
||||
</script>
|
||||
|
@ -93,7 +93,7 @@ onMounted(() => {
|
||||
|
||||
const poolOptions = [
|
||||
{ label: "Interactive", description: "Public indexable, no lifecycle.", value: "interactive" },
|
||||
{ label: "Messaging", description: "Has lifecycle, will delete after 14 days.", value: "messaging" },
|
||||
{ label: "Messaging", description: "Has lifecycle, will be deleted after 14 days.", value: "messaging" },
|
||||
{ label: "Sticker", description: "Public indexable, privilege required.", value: "sticker", disabled: true },
|
||||
{ label: "Dedicated Pool", description: "Your own configuration, coming soon.", value: "dedicated", disabled: true },
|
||||
]
|
||||
@ -201,12 +201,12 @@ async function uploadSingleMultipart(chunkId: string) {
|
||||
const chunkIdx: number = multipartInfo.value["file_chunks"][chunkId]
|
||||
const chunk = content.value.slice(chunkIdx * multipartSize.value, (chunkIdx + 1) * multipartSize.value)
|
||||
|
||||
const data = new FormData()
|
||||
data.set("file", chunk)
|
||||
|
||||
const resp = await solarFetch(`/cgi/uc/attachments/multipart/${multipartInfo.value.rid}/${chunkId}`, {
|
||||
method: "POST",
|
||||
body: data,
|
||||
body: chunk,
|
||||
headers: {
|
||||
"Content-Type": "application/octet-stream",
|
||||
},
|
||||
signal: AbortSignal.timeout(3 * 60 * 1000),
|
||||
})
|
||||
if (resp.status != 200) throw new Error(await resp.text())
|
||||
|
Reference in New Issue
Block a user