2022-06-20 23:12:39 -06:00
|
|
|
<template>
|
|
|
|
<MkStickyContainer>
|
2022-06-20 02:38:49 -06:00
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
2022-11-15 23:12:24 -07:00
|
|
|
<MkSpacer :content-max="800">
|
2022-06-20 23:12:39 -06:00
|
|
|
<transition :name="$store.state.animation ? 'fade' : ''" mode="out-in">
|
|
|
|
<div v-if="page" :key="page.id" v-size="{ max: [450] }" class="xcukqgmh">
|
|
|
|
<div class="_block main">
|
2022-11-18 18:51:57 -07:00
|
|
|
<!--
|
|
|
|
<div class="header">
|
|
|
|
<h1>{{ page.title }}</h1>
|
|
|
|
</div>
|
|
|
|
-->
|
2022-06-20 23:12:39 -06:00
|
|
|
<div class="banner">
|
|
|
|
<img v-if="page.eyeCatchingImageId" :src="page.eyeCatchingImage.url"/>
|
2021-10-14 03:51:15 -06:00
|
|
|
</div>
|
2022-06-20 23:12:39 -06:00
|
|
|
<div class="content">
|
|
|
|
<XPage :page="page"/>
|
2021-10-14 03:51:15 -06:00
|
|
|
</div>
|
2022-06-20 23:12:39 -06:00
|
|
|
<div class="actions">
|
|
|
|
<div class="like">
|
2022-11-13 14:40:04 -07:00
|
|
|
<MkButton v-if="page.isLiked" v-tooltip="i18n.ts._pages.unlike" class="button" primary @click="unlike()"><i class="ph-heart-fill ph-lg"></i><span v-if="page.likedCount > 0" class="count">{{ page.likedCount }}</span></MkButton>
|
|
|
|
<MkButton v-else v-tooltip="i18n.ts._pages.like" class="button" @click="like()"><i class="ph-heart-bold"></i><span v-if="page.likedCount > 0" class="count">{{ page.likedCount }}</span></MkButton>
|
2022-06-20 23:12:39 -06:00
|
|
|
</div>
|
|
|
|
<div class="other">
|
2022-11-06 19:49:47 -07:00
|
|
|
<button v-tooltip="i18n.ts.shareWithNote" v-click-anime class="_button" @click="shareWithNote"><i class="ph-repeat-bold ph-lg ph-fw ph-lg"></i></button>
|
|
|
|
<button v-tooltip="i18n.ts.share" v-click-anime class="_button" @click="share"><i class="ph-share-network-bold ph-lg ph-fw ph-lg"></i></button>
|
2022-06-20 23:12:39 -06:00
|
|
|
</div>
|
2022-11-18 18:54:50 -07:00
|
|
|
<div class="user">
|
|
|
|
<div class="name">
|
|
|
|
<MkAvatar :user="page.user" class="avatar"/>
|
|
|
|
<MkUserName :user="page.user" style="display: block;"/>
|
|
|
|
<MkAcct :user="page.user"/>
|
|
|
|
</div>
|
|
|
|
<MkFollowButton v-if="!$i || $i.id != page.user.id" :user="page.user" :inline="true" :transparent="false" :full="true" class="koudoku"/>
|
2022-06-20 23:12:39 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="links">
|
2022-07-20 07:24:26 -06:00
|
|
|
<MkA :to="`/@${username}/pages/${pageName}/view-source`" class="link">{{ i18n.ts._pages.viewSource }}</MkA>
|
2022-06-20 23:12:39 -06:00
|
|
|
<template v-if="$i && $i.id === page.userId">
|
2022-07-20 07:24:26 -06:00
|
|
|
<MkA :to="`/pages/edit/${page.id}`" class="link">{{ i18n.ts._pages.editThisPage }}</MkA>
|
|
|
|
<button v-if="$i.pinnedPageId === page.id" class="link _textButton" @click="pin(false)">{{ i18n.ts.unpin }}</button>
|
|
|
|
<button v-else class="link _textButton" @click="pin(true)">{{ i18n.ts.pin }}</button>
|
2022-06-20 23:12:39 -06:00
|
|
|
</template>
|
2021-04-25 00:14:26 -06:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-20 23:12:39 -06:00
|
|
|
<div class="footer">
|
2022-11-13 14:36:17 -07:00
|
|
|
<div><i class="ph-alarm-bold"></i> {{ i18n.ts.createdAt }}: <MkTime :time="page.createdAt" mode="detail"/></div>
|
|
|
|
<div v-if="page.createdAt != page.updatedAt"><i class="ph-alarm-bold"></i> {{ i18n.ts.updatedAt }}: <MkTime :time="page.updatedAt" mode="detail"/></div>
|
2021-04-25 00:14:26 -06:00
|
|
|
</div>
|
2022-06-20 23:12:39 -06:00
|
|
|
<MkAd :prefer="['horizontal', 'horizontal-big']"/>
|
|
|
|
<MkContainer :max-height="300" :foldable="true" class="other">
|
2022-11-06 19:49:47 -07:00
|
|
|
<template #header><i class="ph-clock-bold ph-lg"></i> {{ i18n.ts.recentPosts }}</template>
|
2022-06-20 23:12:39 -06:00
|
|
|
<MkPagination v-slot="{items}" :pagination="otherPostsPagination">
|
|
|
|
<MkPagePreview v-for="page in items" :key="page.id" :page="page" class="_gap"/>
|
|
|
|
</MkPagination>
|
|
|
|
</MkContainer>
|
2021-04-25 00:14:26 -06:00
|
|
|
</div>
|
2022-06-20 23:12:39 -06:00
|
|
|
<MkError v-else-if="error" @retry="fetchPage()"/>
|
|
|
|
<MkLoading v-else/>
|
|
|
|
</transition>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2019-07-06 15:56:13 -06:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, watch } from 'vue';
|
2021-11-11 10:02:25 -07:00
|
|
|
import XPage from '@/components/page/page.vue';
|
2022-09-06 03:21:49 -06:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2021-11-11 10:02:25 -07:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { url } from '@/config';
|
2022-08-30 09:24:33 -06:00
|
|
|
import MkFollowButton from '@/components/MkFollowButton.vue';
|
2022-09-06 03:21:49 -06:00
|
|
|
import MkContainer from '@/components/MkContainer.vue';
|
|
|
|
import MkPagination from '@/components/MkPagination.vue';
|
2022-08-30 09:24:33 -06:00
|
|
|
import MkPagePreview from '@/components/MkPagePreview.vue';
|
2022-06-20 02:38:49 -06:00
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
pageName: string;
|
|
|
|
username: string;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
let page = $ref(null);
|
|
|
|
let error = $ref(null);
|
|
|
|
const otherPostsPagination = {
|
|
|
|
endpoint: 'users/pages' as const,
|
|
|
|
limit: 6,
|
|
|
|
params: computed(() => ({
|
|
|
|
userId: page.user.id,
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
const path = $computed(() => props.username + '/' + props.pageName);
|
|
|
|
|
|
|
|
function fetchPage() {
|
|
|
|
page = null;
|
|
|
|
os.api('pages/show', {
|
|
|
|
name: props.pageName,
|
|
|
|
username: props.username,
|
|
|
|
}).then(_page => {
|
|
|
|
page = _page;
|
|
|
|
}).catch(err => {
|
|
|
|
error = err;
|
|
|
|
});
|
|
|
|
}
|
2019-07-06 15:56:13 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
function share() {
|
|
|
|
navigator.share({
|
|
|
|
title: page.title ?? page.name,
|
|
|
|
text: page.summary,
|
|
|
|
url: `${url}/@${page.user.username}/pages/${page.name}`,
|
|
|
|
});
|
|
|
|
}
|
2019-07-06 15:56:13 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
function shareWithNote() {
|
|
|
|
os.post({
|
|
|
|
initialText: `${page.title || page.name} ${url}/@${page.user.username}/pages/${page.name}`,
|
|
|
|
});
|
|
|
|
}
|
2019-07-06 15:56:13 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
function like() {
|
|
|
|
os.apiWithDialog('pages/like', {
|
|
|
|
pageId: page.id,
|
|
|
|
}).then(() => {
|
|
|
|
page.isLiked = true;
|
|
|
|
page.likedCount++;
|
|
|
|
});
|
|
|
|
}
|
2019-07-06 15:56:13 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
async function unlike() {
|
|
|
|
const confirm = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.ts.unlikeConfirm,
|
|
|
|
});
|
|
|
|
if (confirm.canceled) return;
|
|
|
|
os.apiWithDialog('pages/unlike', {
|
|
|
|
pageId: page.id,
|
|
|
|
}).then(() => {
|
|
|
|
page.isLiked = false;
|
|
|
|
page.likedCount--;
|
|
|
|
});
|
|
|
|
}
|
2019-07-06 15:56:13 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
function pin(pin) {
|
|
|
|
os.apiWithDialog('i/update', {
|
|
|
|
pinnedPageId: pin ? page.id : null,
|
|
|
|
});
|
|
|
|
}
|
2019-07-06 15:56:13 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
watch(() => path, fetchPage, { immediate: true });
|
2019-07-06 15:56:13 -06:00
|
|
|
|
2022-06-20 02:38:49 -06:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata(computed(() => page ? {
|
|
|
|
title: computed(() => page.title || page.name),
|
|
|
|
avatar: page.user,
|
|
|
|
path: `/@${page.user.username}/pages/${page.name}`,
|
|
|
|
share: {
|
|
|
|
title: page.title || page.name,
|
|
|
|
text: page.summary,
|
|
|
|
},
|
|
|
|
} : null));
|
2019-07-06 15:56:13 -06:00
|
|
|
</script>
|
2020-01-29 12:37:25 -07:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-25 00:14:26 -06:00
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
}
|
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2020-01-29 12:37:25 -07:00
|
|
|
.xcukqgmh {
|
2020-10-17 05:12:00 -06:00
|
|
|
> .main {
|
2022-11-16 02:00:20 -07:00
|
|
|
|
|
|
|
> * {
|
|
|
|
margin: 1rem;
|
|
|
|
}
|
2021-04-25 00:14:26 -06:00
|
|
|
|
2021-04-10 08:52:45 -06:00
|
|
|
> .header {
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
> h1 {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .banner {
|
2022-11-16 02:15:19 -07:00
|
|
|
margin: 0rem !important;
|
|
|
|
|
2021-04-10 08:52:45 -06:00
|
|
|
> img {
|
2021-04-25 00:14:26 -06:00
|
|
|
// TODO: 良い感じのアスペクト比で表示
|
2021-04-10 08:52:45 -06:00
|
|
|
display: block;
|
|
|
|
width: 100%;
|
2021-04-25 00:14:26 -06:00
|
|
|
height: 150px;
|
2021-04-10 08:52:45 -06:00
|
|
|
object-fit: cover;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .content {
|
2021-04-25 00:14:26 -06:00
|
|
|
padding: 16px 0 0 0;
|
2021-04-10 08:52:45 -06:00
|
|
|
}
|
|
|
|
|
2021-04-25 00:14:26 -06:00
|
|
|
> .actions {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
margin-top: 16px;
|
|
|
|
padding: 16px 0 0 0;
|
2021-04-10 08:52:45 -06:00
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
|
2021-04-25 00:14:26 -06:00
|
|
|
> .like {
|
|
|
|
> .button {
|
2022-11-16 02:07:13 -07:00
|
|
|
--accent: #eb6f92;
|
|
|
|
--X8: #eb6f92;
|
2021-04-25 00:14:26 -06:00
|
|
|
--buttonBg: rgb(216 71 106 / 5%);
|
|
|
|
--buttonHoverBg: rgb(216 71 106 / 10%);
|
2022-11-16 02:07:13 -07:00
|
|
|
color: #eb6f92;
|
2021-04-10 08:52:45 -06:00
|
|
|
|
2021-04-25 00:14:26 -06:00
|
|
|
::v-deep(.count) {
|
|
|
|
margin-left: 0.5em;
|
|
|
|
}
|
2020-10-17 05:12:00 -06:00
|
|
|
}
|
2020-04-17 05:36:51 -06:00
|
|
|
}
|
2021-04-25 00:14:26 -06:00
|
|
|
|
|
|
|
> .other {
|
|
|
|
> button {
|
|
|
|
padding: 8px;
|
|
|
|
margin: 0 8px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--fgHighlighted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-18 18:54:50 -07:00
|
|
|
> .user {
|
|
|
|
margin-left: auto;
|
|
|
|
padding: 16px 0 0 0;
|
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
> .avatar {
|
|
|
|
width: 52px;
|
|
|
|
height: 52px;
|
|
|
|
}
|
2021-04-25 00:14:26 -06:00
|
|
|
|
2022-11-18 18:54:50 -07:00
|
|
|
> .name {
|
|
|
|
margin: 0 0 0 12px;
|
|
|
|
font-size: 90%;
|
|
|
|
}
|
2021-04-25 00:14:26 -06:00
|
|
|
|
2022-11-18 18:54:50 -07:00
|
|
|
> .koudoku {
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
2021-04-25 00:14:26 -06:00
|
|
|
}
|
2020-04-17 05:36:51 -06:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:52:45 -06:00
|
|
|
> .links {
|
2021-04-25 00:14:26 -06:00
|
|
|
margin-top: 16px;
|
2022-11-16 02:12:24 -07:00
|
|
|
padding: 14px 0;
|
2021-04-10 08:52:45 -06:00
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
|
2020-10-17 05:12:00 -06:00
|
|
|
> .link {
|
2022-11-16 02:12:24 -07:00
|
|
|
margin-right: 2em;
|
2020-04-17 05:36:51 -06:00
|
|
|
}
|
2020-04-13 09:13:49 -06:00
|
|
|
}
|
2020-04-05 02:55:51 -06:00
|
|
|
}
|
2021-04-10 08:52:45 -06:00
|
|
|
|
|
|
|
> .footer {
|
2022-11-16 02:12:24 -07:00
|
|
|
margin: var(--margin) 0 var(--margin) 0;
|
2021-04-10 08:52:45 -06:00
|
|
|
font-size: 85%;
|
|
|
|
opacity: 0.75;
|
|
|
|
}
|
2020-01-29 12:37:25 -07:00
|
|
|
}
|
|
|
|
</style>
|