egirlskey/packages/frontend/src/pages/gallery/post.vue

286 lines
7.3 KiB
Vue
Raw Normal View History

<!--
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
<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>
</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">
<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>
新規にフォローした人のwithRepliesをtrueにする機能を追加 (#12048) * feat: add defaultWithReplies to MiUser * feat: use defaultWithReplies when creating MiFollowing * feat: update defaultWithReplies from API * feat: return defaultWithReplies as a part of $i * feat(frontend): configure defaultWithReplies * docs(changelog): 新規にフォローした人のをデフォルトでTL二追加できるように * fix: typo * style: fix lint failure * chore: improve UI text * chore: make optional params of UserFollowingService.follow() object * chore: UserFollowingService.follow() accept withReplies * chore: add withReplies to MiFollowRequest * chore: process withReplies for follow request * feat: accept withReplies on 'following/create' endpoint * feat: store defaultWithReplies in client store * Revert "feat: return defaultWithReplies as a part of $i" This reverts commit f2cc4fe6 * Revert "feat: update defaultWithReplies from API" This reverts commit 95e3cee6 * Revert "feat: add defaultWithReplies to MiUser" This reverts commit 9f5ab14d7063532de2b049bc2ed40a15658168f5. * feat: configuring withReplies in import-following * feat(frontend): configure withReplies * fix(frontend): incorrectly showRepliesToOthersInTimeline can be shown * fix(backend): withReplies of following/create not working * fix(frontend): importFollowing error * fix: withReplies is not working with follow import * fix(frontend): use v-model * style: fix lint --------- Co-authored-by: Sayamame-beans <61457993+sayamame-beans@users.noreply.github.com> Co-authored-by: syuilo <syuilotan@yahoo.co.jp>
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>
</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>
</div>
<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>
</div>
2022-06-30 12:38:34 +00:00
</MkSpacer>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import { computed, watch, ref } from 'vue';
import * as Misskey from 'misskey-js';
import MkButton from '@/components/MkButton.vue';
2023-09-19 07:37:43 +00:00
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import MkContainer from '@/components/MkContainer.vue';
import MkPagination from '@/components/MkPagination.vue';
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';
import { isSupportShare } from '@/scripts/navigator.js';
import copyToClipboard from '@/scripts/copy-to-clipboard.js';
import { useRouter } from '@/router/supplier.js';
const router = useRouter();
const props = defineProps<{
postId: string;
}>();
const post = ref<Misskey.entities.GalleryPost | null>(null);
const error = ref<any>(null);
const otherPostsPagination = {
endpoint: 'users/gallery/posts' as const,
limit: 6,
params: computed(() => ({
userId: post.value.user.id,
})),
};
function fetchPost() {
post.value = null;
misskeyApi('gallery/posts/show', {
postId: props.postId,
}).then(_post => {
post.value = _post;
}).catch(_error => {
error.value = _error;
});
}
function copyLink() {
copyToClipboard(`${url}/gallery/${post.value.id}`);
os.success();
}
function share() {
navigator.share({
title: post.value.title,
text: post.value.description,
url: `${url}/gallery/${post.value.id}`,
});
}
function shareWithNote() {
os.post({
initialText: `${post.value.title} ${url}/gallery/${post.value.id}`,
});
}
function like() {
os.apiWithDialog('gallery/posts/like', {
postId: props.postId,
}).then(() => {
post.value.isLiked = true;
post.value.likedCount++;
});
}
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(() => {
post.value.isLiked = false;
post.value.likedCount--;
});
}
function edit() {
router.push(`/gallery/${post.value.id}/edit`);
}
watch(() => props.postId, fetchPost, { immediate: true });
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,
}]);
const headerTabs = computed(() => []);
definePageMetadata(() => ({
title: post.value ? post.value.title : i18n.ts.gallery,
...post.value ? {
avatar: post.value.user,
} : {},
}));
</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;
flex-wrap: wrap;
> .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>