2021-04-24 15:38:24 +02:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header
|
|
|
|
><MkPageHeader :actions="headerActions" :tabs="headerTabs"
|
|
|
|
/></template>
|
|
|
|
<MkSpacer :content-max="1000" :margin-min="16" :margin-max="32">
|
|
|
|
<div class="_root">
|
|
|
|
<transition
|
|
|
|
:name="$store.state.animation ? 'fade' : ''"
|
|
|
|
mode="out-in"
|
|
|
|
>
|
|
|
|
<div v-if="post" class="rkxwuolj">
|
|
|
|
<div class="files">
|
|
|
|
<div
|
|
|
|
v-for="file in post.files"
|
|
|
|
:key="file.id"
|
|
|
|
class="file"
|
|
|
|
>
|
|
|
|
<img :src="file.url" />
|
|
|
|
</div>
|
2022-06-30 14:38:34 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="body _block">
|
|
|
|
<div class="title">{{ post.title }}</div>
|
|
|
|
<div class="description">
|
|
|
|
<Mfm :text="post.description" />
|
2022-06-30 14:38:34 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="info">
|
|
|
|
<i class="ph-clock ph-bold ph-lg"></i>
|
|
|
|
<MkTime :time="post.createdAt" mode="detail" />
|
2022-06-30 14:38:34 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="actions">
|
|
|
|
<div class="like">
|
|
|
|
<MkButton
|
|
|
|
v-if="post.isLiked"
|
|
|
|
v-tooltip="i18n.ts._gallery.unlike"
|
|
|
|
class="button"
|
|
|
|
primary
|
|
|
|
@click="unlike()"
|
|
|
|
><i class="ph-heart ph-fill ph-lg"></i
|
|
|
|
><span
|
|
|
|
v-if="post.likedCount > 0"
|
|
|
|
class="count"
|
|
|
|
>{{ post.likedCount }}</span
|
|
|
|
></MkButton
|
|
|
|
>
|
|
|
|
<MkButton
|
|
|
|
v-else
|
|
|
|
v-tooltip="i18n.ts._gallery.like"
|
|
|
|
class="button"
|
|
|
|
@click="like()"
|
|
|
|
><i class="ph-heart ph-bold"></i
|
|
|
|
><span
|
|
|
|
v-if="post.likedCount > 0"
|
|
|
|
class="count"
|
|
|
|
>{{ post.likedCount }}</span
|
|
|
|
></MkButton
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
<div class="other">
|
|
|
|
<button
|
|
|
|
v-if="$i && $i.id === post.user.id"
|
|
|
|
v-tooltip="i18n.ts.edit"
|
|
|
|
v-click-anime
|
|
|
|
class="_button"
|
|
|
|
@click="edit"
|
|
|
|
>
|
|
|
|
<i
|
|
|
|
class="ph-pencil ph-bold ph-lg ph-fw ph-lg"
|
|
|
|
></i>
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
v-tooltip="i18n.ts.shareWithNote"
|
|
|
|
v-click-anime
|
|
|
|
class="_button"
|
|
|
|
@click="shareWithNote"
|
|
|
|
>
|
|
|
|
<i
|
|
|
|
class="ph-repeat ph-bold ph-lg ph-fw ph-lg"
|
|
|
|
></i>
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
v-if="shareAvailable()"
|
|
|
|
v-tooltip="i18n.ts.share"
|
|
|
|
v-click-anime
|
|
|
|
class="_button"
|
|
|
|
@click="share"
|
|
|
|
>
|
|
|
|
<i
|
|
|
|
class="ph-share-network ph-bold ph-lg ph-fw ph-lg"
|
|
|
|
></i>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="user">
|
|
|
|
<MkAvatar :user="post.user" class="avatar" />
|
|
|
|
<div class="name">
|
|
|
|
<MkUserName
|
|
|
|
:user="post.user"
|
|
|
|
style="display: block"
|
|
|
|
/>
|
|
|
|
<MkAcct :user="post.user" />
|
|
|
|
</div>
|
|
|
|
<MkFollowButton
|
|
|
|
v-if="!$i || $i.id != post.user.id"
|
|
|
|
:user="post.user"
|
|
|
|
:inline="true"
|
|
|
|
:transparent="false"
|
|
|
|
:full="true"
|
|
|
|
large
|
|
|
|
class="koudoku"
|
|
|
|
/>
|
2022-06-30 14:38:34 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-04-26 23:38:44 +02:00
|
|
|
<MkAd :prefer="['inline', 'inline-big']" />
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkContainer
|
|
|
|
:max-height="300"
|
|
|
|
:foldable="true"
|
|
|
|
class="other"
|
|
|
|
>
|
|
|
|
<template #header
|
|
|
|
><i class="ph-clock ph-bold ph-lg"></i>
|
|
|
|
{{ i18n.ts.recentPosts }}</template
|
|
|
|
>
|
|
|
|
<MkPagination
|
|
|
|
v-slot="{ items }"
|
|
|
|
:pagination="otherPostsPagination"
|
|
|
|
>
|
|
|
|
<div class="sdrarzaf">
|
|
|
|
<MkGalleryPostPreview
|
|
|
|
v-for="post in items"
|
|
|
|
:key="post.id"
|
|
|
|
:post="post"
|
|
|
|
class="post"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</MkPagination>
|
|
|
|
</MkContainer>
|
2021-04-24 15:38:24 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkError v-else-if="error" @retry="fetch()" />
|
|
|
|
<MkLoading v-else />
|
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2021-04-24 15:38:24 +02:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import { computed, defineComponent, inject, watch } from "vue";
|
|
|
|
import MkButton from "@/components/MkButton.vue";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import MkContainer from "@/components/MkContainer.vue";
|
|
|
|
import ImgWithBlurhash from "@/components/MkImgWithBlurhash.vue";
|
|
|
|
import MkPagination from "@/components/MkPagination.vue";
|
|
|
|
import MkGalleryPostPreview from "@/components/MkGalleryPostPreview.vue";
|
|
|
|
import MkFollowButton from "@/components/MkFollowButton.vue";
|
|
|
|
import { url } from "@/config";
|
|
|
|
import { useRouter } from "@/router";
|
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
|
|
|
import { shareAvailable } from "@/scripts/share-available";
|
2022-06-20 10:38:49 +02:00
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
postId: string;
|
|
|
|
}>();
|
|
|
|
|
2022-07-04 16:22:11 +02:00
|
|
|
let post = $ref(null);
|
|
|
|
let error = $ref(null);
|
2022-06-20 10:38:49 +02:00
|
|
|
const otherPostsPagination = {
|
2023-04-08 02:01:42 +02:00
|
|
|
endpoint: "users/gallery/posts" as const,
|
2022-06-20 10:38:49 +02:00
|
|
|
limit: 6,
|
|
|
|
params: computed(() => ({
|
|
|
|
userId: post.user.id,
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
|
|
|
|
function fetchPost() {
|
|
|
|
post = null;
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("gallery/posts/show", {
|
2022-06-20 10:38:49 +02:00
|
|
|
postId: props.postId,
|
2023-04-08 02:01:42 +02:00
|
|
|
})
|
|
|
|
.then((_post) => {
|
|
|
|
post = _post;
|
|
|
|
})
|
|
|
|
.catch((_error) => {
|
|
|
|
error = _error;
|
|
|
|
});
|
2022-06-20 10:38:49 +02:00
|
|
|
}
|
2021-04-24 15:38:24 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
function share() {
|
|
|
|
navigator.share({
|
|
|
|
title: post.title,
|
|
|
|
text: post.description,
|
|
|
|
url: `${url}/gallery/${post.id}`,
|
|
|
|
});
|
|
|
|
}
|
2021-04-24 15:38:24 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
function shareWithNote() {
|
|
|
|
os.post({
|
|
|
|
initialText: `${post.title} ${url}/gallery/${post.id}`,
|
|
|
|
});
|
|
|
|
}
|
2021-04-24 15:38:24 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
function like() {
|
2023-04-18 20:58:04 +02:00
|
|
|
os.api("gallery/posts/like", {
|
2022-06-20 10:38:49 +02:00
|
|
|
postId: props.postId,
|
|
|
|
}).then(() => {
|
|
|
|
post.isLiked = true;
|
|
|
|
post.likedCount++;
|
|
|
|
});
|
|
|
|
}
|
2021-04-24 15:38:24 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
async function unlike() {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("gallery/posts/unlike", {
|
2022-06-20 10:38:49 +02:00
|
|
|
postId: props.postId,
|
|
|
|
}).then(() => {
|
|
|
|
post.isLiked = false;
|
|
|
|
post.likedCount--;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function edit() {
|
|
|
|
router.push(`/gallery/${post.id}/edit`);
|
|
|
|
}
|
|
|
|
|
|
|
|
watch(() => props.postId, fetchPost, { immediate: true });
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
const headerActions = $computed(() => [
|
|
|
|
{
|
|
|
|
icon: "ph-pencil ph-bold ph-lg",
|
|
|
|
text: i18n.ts.edit,
|
|
|
|
handler: edit,
|
|
|
|
},
|
|
|
|
]);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
definePageMetadata(
|
|
|
|
computed(() =>
|
|
|
|
post
|
|
|
|
? {
|
|
|
|
title: post.title,
|
|
|
|
avatar: post.user,
|
|
|
|
}
|
|
|
|
: null
|
|
|
|
)
|
|
|
|
);
|
2021-04-24 15:38:24 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
}
|
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
.rkxwuolj {
|
|
|
|
> .files {
|
|
|
|
> .file {
|
|
|
|
> img {
|
|
|
|
display: block;
|
|
|
|
max-width: 100%;
|
|
|
|
max-height: 500px;
|
|
|
|
margin: 0 auto;
|
2023-04-18 20:58:04 +02:00
|
|
|
border-radius: 10px;
|
2021-04-24 15:38:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
& + .file {
|
|
|
|
margin-top: 16px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .body {
|
|
|
|
padding: 32px;
|
|
|
|
|
|
|
|
> .title {
|
|
|
|
font-weight: bold;
|
|
|
|
font-size: 1.2em;
|
|
|
|
margin-bottom: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .info {
|
|
|
|
margin-top: 16px;
|
|
|
|
font-size: 90%;
|
|
|
|
opacity: 0.7;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .actions {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
margin-top: 16px;
|
|
|
|
padding: 16px 0 0 0;
|
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
|
|
|
|
> .like {
|
|
|
|
> .button {
|
2022-11-16 10:07:13 +01:00
|
|
|
--accent: #eb6f92;
|
|
|
|
--X8: #eb6f92;
|
2021-04-24 15:38:24 +02:00
|
|
|
--buttonBg: rgb(216 71 106 / 5%);
|
|
|
|
--buttonHoverBg: rgb(216 71 106 / 10%);
|
2022-11-16 10:07:13 +01:00
|
|
|
color: #eb6f92;
|
2021-04-24 15:38:24 +02:00
|
|
|
|
|
|
|
::v-deep(.count) {
|
|
|
|
margin-left: 0.5em;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .other {
|
|
|
|
margin-left: auto;
|
|
|
|
|
|
|
|
> button {
|
|
|
|
padding: 8px;
|
|
|
|
margin: 0 8px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--fgHighlighted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .user {
|
|
|
|
margin-top: 16px;
|
|
|
|
padding: 16px 0 0 0;
|
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
width: 52px;
|
|
|
|
height: 52px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .name {
|
|
|
|
margin: 0 0 0 12px;
|
|
|
|
font-size: 90%;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .koudoku {
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.sdrarzaf {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
|
|
|
grid-gap: 12px;
|
|
|
|
margin: var(--margin);
|
|
|
|
|
|
|
|
> .post {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|