2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
2024-02-13 15:59:27 +00:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 05:31:52 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2021-04-24 13:38:24 +00:00
|
|
|
<template>
|
2022-06-30 12:38:34 +00:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-05-29 08:13:12 +00:00
|
|
|
<MkSpacer :contentMax="1000" :marginMin="16" :marginMax="32">
|
2022-06-30 12:38:34 +00:00
|
|
|
<div class="_root">
|
2023-04-01 04:42:40 +00:00
|
|
|
<Transition :name="defaultStore.state.animation ? 'fade' : ''" mode="out-in">
|
2022-06-30 12:38:34 +00:00
|
|
|
<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>
|
2021-04-24 13:38:24 +00:00
|
|
|
</div>
|
2023-01-06 00:41:14 +00:00
|
|
|
<div class="body">
|
2022-06-30 12:38:34 +00:00
|
|
|
<div class="title">{{ post.title }}</div>
|
|
|
|
<div class="description"><Mfm :text="post.description"/></div>
|
|
|
|
<div class="info">
|
2023-09-30 19:53:52 +00:00
|
|
|
<i class="ph-clock ph-bold ph-lg"></i> <MkTime :time="post.createdAt" mode="detail"/>
|
2022-06-30 12:38:34 +00:00
|
|
|
</div>
|
|
|
|
<div class="actions">
|
|
|
|
<div class="like">
|
2024-02-27 05:36:53 +00:00
|
|
|
<MkButton v-if="post.isLiked" v-tooltip="i18n.ts._gallery.unlike" class="button" primary @click="unlike()"><i class="ph-star-break ph-bold 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-star ph-bold ph-lg"></i><span v-if="post.likedCount > 0" class="count">{{ post.likedCount }}</span></MkButton>
|
2022-06-30 12:38:34 +00:00
|
|
|
</div>
|
|
|
|
<div class="other">
|
2024-02-05 11:39:15 +00:00
|
|
|
<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-simple ph-bold ph-lg ti-fw"></i></button>
|
2023-09-30 19:53:52 +00:00
|
|
|
<button v-tooltip="i18n.ts.shareWithNote" v-click-anime class="_button" @click="shareWithNote"><i class="ph-repeat ph-bold ph-lg ti-fw"></i></button>
|
2023-12-23 01:09:23 +00:00
|
|
|
<button v-tooltip="i18n.ts.copyLink" v-click-anime class="_button" @click="copyLink"><i class="ph-share-network ph-bold ph-lg ti-fw"></i></button>
|
|
|
|
<button v-if="isSupportShare()" v-tooltip="i18n.ts.share" v-click-anime class="_button" @click="share"><i class="ph-share-network ph-bold ph-lg ti-fw"></i></button>
|
2022-06-30 12:38:34 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="user">
|
2023-01-16 05:18:11 +00:00
|
|
|
<MkAvatar :user="post.user" class="avatar" link preview/>
|
2022-06-30 12:38:34 +00:00
|
|
|
<div class="name">
|
2023-02-08 11:07:19 +00:00
|
|
|
<MkUserName :user="post.user" style="display: block;"/>
|
2022-06-30 12:38:34 +00:00
|
|
|
<MkAcct :user="post.user"/>
|
|
|
|
</div>
|
2023-10-17 11:56:17 +00:00
|
|
|
<MkFollowButton v-if="!$i || $i.id != post.user.id" v-model:user="post.user" :inline="true" :transparent="false" :full="true" large class="koudoku"/>
|
2022-06-30 12:38:34 +00:00
|
|
|
</div>
|
2021-04-24 13:38:24 +00:00
|
|
|
</div>
|
2022-06-30 12:38:34 +00:00
|
|
|
<MkAd :prefer="['horizontal', 'horizontal-big']"/>
|
|
|
|
<MkContainer :max-height="300" :foldable="true" class="other">
|
2023-09-30 19:53:52 +00:00
|
|
|
<template #icon><i class="ph-clock ph-bold ph-lg"></i></template>
|
2023-01-14 23:30:29 +00:00
|
|
|
<template #header>{{ i18n.ts.recentPosts }}</template>
|
2022-06-30 12:38:34 +00:00
|
|
|
<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 13:38:24 +00:00
|
|
|
</div>
|
2023-02-12 07:52:48 +00:00
|
|
|
<MkError v-else-if="error" @retry="fetchPost()"/>
|
2022-06-30 12:38:34 +00:00
|
|
|
<MkLoading v-else/>
|
2022-12-30 04:37:14 +00:00
|
|
|
</Transition>
|
2021-04-24 13:38:24 +00:00
|
|
|
</div>
|
2022-06-30 12:38:34 +00:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2021-04-24 13:38:24 +00:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
<script lang="ts" setup>
|
2023-12-07 05:42:09 +00:00
|
|
|
import { computed, watch, ref } from 'vue';
|
2023-12-26 05:19:35 +00:00
|
|
|
import * as Misskey from 'misskey-js';
|
2022-09-06 09:21:49 +00:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import * as os from '@/os.js';
|
2024-01-04 09:32:46 +00:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2022-09-06 09:21:49 +00:00
|
|
|
import MkContainer from '@/components/MkContainer.vue';
|
2023-12-27 06:55:09 +00:00
|
|
|
import MkPagination from '@/components/MkPagination.vue';
|
2022-08-30 15:24:33 +00:00
|
|
|
import MkGalleryPostPreview from '@/components/MkGalleryPostPreview.vue';
|
|
|
|
import MkFollowButton from '@/components/MkFollowButton.vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { url } from '@/config.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
import { defaultStore } from '@/store.js';
|
|
|
|
import { $i } from '@/account.js';
|
2023-11-29 23:15:13 +00:00
|
|
|
import { isSupportShare } from '@/scripts/navigator.js';
|
|
|
|
import copyToClipboard from '@/scripts/copy-to-clipboard.js';
|
2024-01-30 12:07:34 +00:00
|
|
|
import { useRouter } from '@/router/supplier.js';
|
2022-06-20 08:38:49 +00:00
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
postId: string;
|
|
|
|
}>();
|
|
|
|
|
2023-12-26 05:19:35 +00:00
|
|
|
const post = ref<Misskey.entities.GalleryPost | null>(null);
|
|
|
|
const error = ref<any>(null);
|
2022-06-20 08:38:49 +00:00
|
|
|
const otherPostsPagination = {
|
|
|
|
endpoint: 'users/gallery/posts' as const,
|
|
|
|
limit: 6,
|
|
|
|
params: computed(() => ({
|
2023-12-07 05:42:09 +00:00
|
|
|
userId: post.value.user.id,
|
2022-06-20 08:38:49 +00:00
|
|
|
})),
|
2023-12-27 06:55:09 +00:00
|
|
|
};
|
2022-06-20 08:38:49 +00:00
|
|
|
|
|
|
|
function fetchPost() {
|
2023-12-07 05:42:09 +00:00
|
|
|
post.value = null;
|
2024-01-04 09:32:46 +00:00
|
|
|
misskeyApi('gallery/posts/show', {
|
2022-06-20 08:38:49 +00:00
|
|
|
postId: props.postId,
|
|
|
|
}).then(_post => {
|
2023-12-07 05:42:09 +00:00
|
|
|
post.value = _post;
|
2022-06-20 08:38:49 +00:00
|
|
|
}).catch(_error => {
|
2023-12-07 05:42:09 +00:00
|
|
|
error.value = _error;
|
2022-06-20 08:38:49 +00:00
|
|
|
});
|
|
|
|
}
|
2021-04-24 13:38:24 +00:00
|
|
|
|
2023-11-29 23:15:13 +00:00
|
|
|
function copyLink() {
|
2023-12-07 05:42:09 +00:00
|
|
|
copyToClipboard(`${url}/gallery/${post.value.id}`);
|
2023-11-29 23:15:13 +00:00
|
|
|
os.success();
|
|
|
|
}
|
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
function share() {
|
|
|
|
navigator.share({
|
2023-12-07 05:42:09 +00:00
|
|
|
title: post.value.title,
|
|
|
|
text: post.value.description,
|
|
|
|
url: `${url}/gallery/${post.value.id}`,
|
2022-06-20 08:38:49 +00:00
|
|
|
});
|
|
|
|
}
|
2021-04-24 13:38:24 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
function shareWithNote() {
|
|
|
|
os.post({
|
2023-12-07 05:42:09 +00:00
|
|
|
initialText: `${post.value.title} ${url}/gallery/${post.value.id}`,
|
2022-06-20 08:38:49 +00:00
|
|
|
});
|
|
|
|
}
|
2021-04-24 13:38:24 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
function like() {
|
|
|
|
os.apiWithDialog('gallery/posts/like', {
|
|
|
|
postId: props.postId,
|
|
|
|
}).then(() => {
|
2023-12-07 05:42:09 +00:00
|
|
|
post.value.isLiked = true;
|
|
|
|
post.value.likedCount++;
|
2022-06-20 08:38:49 +00:00
|
|
|
});
|
|
|
|
}
|
2021-04-24 13:38:24 +00:00
|
|
|
|
2022-06-20 08:38:49 +00:00
|
|
|
async function unlike() {
|
|
|
|
const confirm = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.ts.unlikeConfirm,
|
|
|
|
});
|
|
|
|
if (confirm.canceled) return;
|
|
|
|
os.apiWithDialog('gallery/posts/unlike', {
|
|
|
|
postId: props.postId,
|
|
|
|
}).then(() => {
|
2023-12-07 05:42:09 +00:00
|
|
|
post.value.isLiked = false;
|
|
|
|
post.value.likedCount--;
|
2022-06-20 08:38:49 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function edit() {
|
2023-12-07 05:42:09 +00:00
|
|
|
router.push(`/gallery/${post.value.id}/edit`);
|
2022-06-20 08:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
watch(() => props.postId, fetchPost, { immediate: true });
|
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const headerActions = computed(() => [{
|
2024-02-05 11:39:15 +00:00
|
|
|
icon: 'ph-pencil-simple ph-bold ph-lg',
|
2022-06-30 12:38:34 +00:00
|
|
|
text: i18n.ts.edit,
|
|
|
|
handler: edit,
|
|
|
|
}]);
|
2022-06-20 08:38:49 +00:00
|
|
|
|
2023-12-07 05:42:09 +00:00
|
|
|
const headerTabs = computed(() => []);
|
2022-06-20 08:38:49 +00:00
|
|
|
|
2024-02-16 07:17:09 +00:00
|
|
|
definePageMetadata(() => ({
|
|
|
|
title: post.value ? post.value.title : i18n.ts.gallery,
|
|
|
|
...post.value ? {
|
|
|
|
avatar: post.value.user,
|
|
|
|
} : {},
|
|
|
|
}));
|
2021-04-24 13:38:24 +00: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
& + .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 {
|
|
|
|
--accent: rgb(241 97 132);
|
|
|
|
--X8: rgb(241 92 128);
|
|
|
|
--buttonBg: rgb(216 71 106 / 5%);
|
|
|
|
--buttonHoverBg: rgb(216 71 106 / 10%);
|
|
|
|
color: #ff002f;
|
|
|
|
|
|
|
|
::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;
|
2023-07-19 23:11:16 +00:00
|
|
|
flex-wrap: wrap;
|
2021-04-24 13:38:24 +00:00
|
|
|
|
|
|
|
> .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>
|