2023-07-27 00:31:52 -05:00
|
|
|
<!--
|
2024-02-13 09:59:27 -06:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 00:31:52 -05:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2022-06-21 00:12:39 -05:00
|
|
|
<template>
|
|
|
|
<MkStickyContainer>
|
2022-06-20 03:38:49 -05:00
|
|
|
<template #header><MkPageHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-05-19 02:20:53 -05:00
|
|
|
<MkSpacer :contentMax="700">
|
2023-03-31 23:42:40 -05:00
|
|
|
<Transition :name="defaultStore.state.animation ? 'fade' : ''" mode="out-in">
|
2022-12-25 17:40:13 -06:00
|
|
|
<div v-if="page" :key="page.id" class="xcukqgmh">
|
2023-01-05 18:41:14 -06:00
|
|
|
<div class="main">
|
2022-06-21 00:12:39 -05:00
|
|
|
<!--
|
2021-10-23 14:03:07 -05:00
|
|
|
<div class="header">
|
|
|
|
<h1>{{ page.title }}</h1>
|
|
|
|
</div>
|
|
|
|
-->
|
2022-06-21 00:12:39 -05:00
|
|
|
<div class="banner">
|
2023-09-10 04:40:20 -05:00
|
|
|
<MkMediaImage
|
|
|
|
v-if="page.eyeCatchingImageId"
|
|
|
|
:image="page.eyeCatchingImage"
|
|
|
|
:cover="true"
|
|
|
|
:disableImageLink="true"
|
|
|
|
class="thumbnail"
|
|
|
|
/>
|
2021-10-14 04:51:15 -05:00
|
|
|
</div>
|
2022-06-21 00:12:39 -05:00
|
|
|
<div class="content">
|
|
|
|
<XPage :page="page"/>
|
2021-10-14 04:51:15 -05:00
|
|
|
</div>
|
2022-06-21 00:12:39 -05:00
|
|
|
<div class="actions">
|
|
|
|
<div class="like">
|
2023-05-19 02:20:53 -05:00
|
|
|
<MkButton v-if="page.isLiked" v-tooltip="i18n.ts._pages.unlike" class="button" asLike primary @click="unlike()"><i class="ti ti-heart-off"></i><span v-if="page.likedCount > 0" class="count">{{ page.likedCount }}</span></MkButton>
|
|
|
|
<MkButton v-else v-tooltip="i18n.ts._pages.like" class="button" asLike @click="like()"><i class="ti ti-heart"></i><span v-if="page.likedCount > 0" class="count">{{ page.likedCount }}</span></MkButton>
|
2022-06-21 00:12:39 -05:00
|
|
|
</div>
|
|
|
|
<div class="other">
|
2022-12-19 04:01:30 -06:00
|
|
|
<button v-tooltip="i18n.ts.shareWithNote" v-click-anime class="_button" @click="shareWithNote"><i class="ti ti-repeat ti-fw"></i></button>
|
2023-11-29 17:15:13 -06:00
|
|
|
<button v-tooltip="i18n.ts.copyLink" v-click-anime class="_button" @click="copyLink"><i class="ti ti-link ti-fw"></i></button>
|
|
|
|
<button v-if="isSupportShare()" v-tooltip="i18n.ts.share" v-click-anime class="_button" @click="share"><i class="ti ti-share ti-fw"></i></button>
|
2022-06-21 00:12:39 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="user">
|
2023-01-15 23:18:11 -06:00
|
|
|
<MkAvatar :user="page.user" class="avatar" link preview/>
|
2022-06-21 00:12:39 -05:00
|
|
|
<div class="name">
|
2023-02-08 05:07:19 -06:00
|
|
|
<MkUserName :user="page.user" style="display: block;"/>
|
2022-06-21 00:12:39 -05:00
|
|
|
<MkAcct :user="page.user"/>
|
|
|
|
</div>
|
|
|
|
<MkFollowButton v-if="!$i || $i.id != page.user.id" :user="page.user" :inline="true" :transparent="false" :full="true" large class="koudoku"/>
|
|
|
|
</div>
|
|
|
|
<div class="links">
|
2022-07-20 08:24:26 -05:00
|
|
|
<MkA :to="`/@${username}/pages/${pageName}/view-source`" class="link">{{ i18n.ts._pages.viewSource }}</MkA>
|
2022-06-21 00:12:39 -05:00
|
|
|
<template v-if="$i && $i.id === page.userId">
|
2022-07-20 08:24:26 -05: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-21 00:12:39 -05:00
|
|
|
</template>
|
2021-04-25 01:14:26 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-21 00:12:39 -05:00
|
|
|
<div class="footer">
|
2022-12-20 00:24:31 -06:00
|
|
|
<div><i class="ti ti-clock"></i> {{ i18n.ts.createdAt }}: <MkTime :time="page.createdAt" mode="detail"/></div>
|
|
|
|
<div v-if="page.createdAt != page.updatedAt"><i class="ti ti-clock"></i> {{ i18n.ts.updatedAt }}: <MkTime :time="page.updatedAt" mode="detail"/></div>
|
2021-04-25 01:14:26 -05:00
|
|
|
</div>
|
2022-06-21 00:12:39 -05:00
|
|
|
<MkAd :prefer="['horizontal', 'horizontal-big']"/>
|
|
|
|
<MkContainer :max-height="300" :foldable="true" class="other">
|
2023-01-14 17:30:29 -06:00
|
|
|
<template #icon><i class="ti ti-clock"></i></template>
|
|
|
|
<template #header>{{ i18n.ts.recentPosts }}</template>
|
2023-09-10 04:40:20 -05:00
|
|
|
<MkPagination v-slot="{items}" :pagination="otherPostsPagination" :class="$style.relatedPagesRoot" class="_gaps">
|
|
|
|
<MkPagePreview v-for="page in items" :key="page.id" :page="page" :class="$style.relatedPagesItem"/>
|
2022-06-21 00:12:39 -05:00
|
|
|
</MkPagination>
|
|
|
|
</MkContainer>
|
2021-04-25 01:14:26 -05:00
|
|
|
</div>
|
2022-06-21 00:12:39 -05:00
|
|
|
<MkError v-else-if="error" @retry="fetchPage()"/>
|
|
|
|
<MkLoading v-else/>
|
2022-12-29 22:37:14 -06:00
|
|
|
</Transition>
|
2022-06-21 00:12:39 -05:00
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2019-07-06 16:56:13 -05:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
<script lang="ts" setup>
|
2023-12-06 23:42:09 -06:00
|
|
|
import { computed, watch, ref } from 'vue';
|
2023-12-25 23:19:35 -06:00
|
|
|
import * as Misskey from 'misskey-js';
|
2021-11-11 11:02:25 -06:00
|
|
|
import XPage from '@/components/page/page.vue';
|
2022-09-06 04:21:49 -05:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-09-19 02:37:43 -05:00
|
|
|
import * as os from '@/os.js';
|
2024-01-04 03:32:46 -06:00
|
|
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
2023-09-19 02:37:43 -05:00
|
|
|
import { url } from '@/config.js';
|
2023-09-10 04:40:20 -05:00
|
|
|
import MkMediaImage from '@/components/MkMediaImage.vue';
|
2022-08-30 10:24:33 -05:00
|
|
|
import MkFollowButton from '@/components/MkFollowButton.vue';
|
2022-09-06 04:21:49 -05:00
|
|
|
import MkContainer from '@/components/MkContainer.vue';
|
2023-12-27 00:55:09 -06:00
|
|
|
import MkPagination from '@/components/MkPagination.vue';
|
2022-08-30 10:24:33 -05:00
|
|
|
import MkPagePreview from '@/components/MkPagePreview.vue';
|
2023-09-19 02:37:43 -05:00
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
import { pageViewInterruptors, defaultStore } from '@/store.js';
|
|
|
|
import { deepClone } from '@/scripts/clone.js';
|
|
|
|
import { $i } from '@/account.js';
|
2023-11-29 17:15:13 -06:00
|
|
|
import { isSupportShare } from '@/scripts/navigator.js';
|
|
|
|
import copyToClipboard from '@/scripts/copy-to-clipboard.js';
|
2022-06-20 03:38:49 -05:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
pageName: string;
|
|
|
|
username: string;
|
|
|
|
}>();
|
|
|
|
|
2023-12-25 23:19:35 -06:00
|
|
|
const page = ref<Misskey.entities.Page | null>(null);
|
|
|
|
const error = ref<any>(null);
|
2022-06-20 03:38:49 -05:00
|
|
|
const otherPostsPagination = {
|
|
|
|
endpoint: 'users/pages' as const,
|
|
|
|
limit: 6,
|
|
|
|
params: computed(() => ({
|
2023-12-06 23:42:09 -06:00
|
|
|
userId: page.value.user.id,
|
2022-06-20 03:38:49 -05:00
|
|
|
})),
|
2023-12-27 00:55:09 -06:00
|
|
|
};
|
2023-12-06 23:42:09 -06:00
|
|
|
const path = computed(() => props.username + '/' + props.pageName);
|
2022-06-20 03:38:49 -05:00
|
|
|
|
|
|
|
function fetchPage() {
|
2023-12-06 23:42:09 -06:00
|
|
|
page.value = null;
|
2024-01-04 03:32:46 -06:00
|
|
|
misskeyApi('pages/show', {
|
2022-06-20 03:38:49 -05:00
|
|
|
name: props.pageName,
|
|
|
|
username: props.username,
|
2023-03-14 20:44:24 -05:00
|
|
|
}).then(async _page => {
|
2023-12-06 23:42:09 -06:00
|
|
|
page.value = _page;
|
2023-03-14 20:44:24 -05:00
|
|
|
|
|
|
|
// plugin
|
|
|
|
if (pageViewInterruptors.length > 0) {
|
|
|
|
let result = deepClone(_page);
|
|
|
|
for (const interruptor of pageViewInterruptors) {
|
|
|
|
result = await interruptor.handler(result);
|
|
|
|
}
|
2023-12-06 23:42:09 -06:00
|
|
|
page.value = result;
|
2023-03-14 20:44:24 -05:00
|
|
|
}
|
2022-06-20 03:38:49 -05:00
|
|
|
}).catch(err => {
|
2023-12-06 23:42:09 -06:00
|
|
|
error.value = err;
|
2022-06-20 03:38:49 -05:00
|
|
|
});
|
|
|
|
}
|
2019-07-06 16:56:13 -05:00
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
function share() {
|
|
|
|
navigator.share({
|
2023-12-06 23:42:09 -06:00
|
|
|
title: page.value.title ?? page.value.name,
|
|
|
|
text: page.value.summary,
|
|
|
|
url: `${url}/@${page.value.user.username}/pages/${page.value.name}`,
|
2022-06-20 03:38:49 -05:00
|
|
|
});
|
|
|
|
}
|
2019-07-06 16:56:13 -05:00
|
|
|
|
2023-11-29 17:15:13 -06:00
|
|
|
function copyLink() {
|
2023-12-06 23:42:09 -06:00
|
|
|
copyToClipboard(`${url}/@${page.value.user.username}/pages/${page.value.name}`);
|
2023-11-29 17:15:13 -06:00
|
|
|
os.success();
|
|
|
|
}
|
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
function shareWithNote() {
|
|
|
|
os.post({
|
2023-12-06 23:42:09 -06:00
|
|
|
initialText: `${page.value.title || page.value.name} ${url}/@${page.value.user.username}/pages/${page.value.name}`,
|
2022-06-20 03:38:49 -05:00
|
|
|
});
|
|
|
|
}
|
2019-07-06 16:56:13 -05:00
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
function like() {
|
|
|
|
os.apiWithDialog('pages/like', {
|
2023-12-06 23:42:09 -06:00
|
|
|
pageId: page.value.id,
|
2022-06-20 03:38:49 -05:00
|
|
|
}).then(() => {
|
2023-12-06 23:42:09 -06:00
|
|
|
page.value.isLiked = true;
|
|
|
|
page.value.likedCount++;
|
2022-06-20 03:38:49 -05:00
|
|
|
});
|
|
|
|
}
|
2019-07-06 16:56:13 -05:00
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
async function unlike() {
|
|
|
|
const confirm = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.ts.unlikeConfirm,
|
|
|
|
});
|
|
|
|
if (confirm.canceled) return;
|
|
|
|
os.apiWithDialog('pages/unlike', {
|
2023-12-06 23:42:09 -06:00
|
|
|
pageId: page.value.id,
|
2022-06-20 03:38:49 -05:00
|
|
|
}).then(() => {
|
2023-12-06 23:42:09 -06:00
|
|
|
page.value.isLiked = false;
|
|
|
|
page.value.likedCount--;
|
2022-06-20 03:38:49 -05:00
|
|
|
});
|
|
|
|
}
|
2019-07-06 16:56:13 -05:00
|
|
|
|
2022-06-20 03:38:49 -05:00
|
|
|
function pin(pin) {
|
|
|
|
os.apiWithDialog('i/update', {
|
2023-12-06 23:42:09 -06:00
|
|
|
pinnedPageId: pin ? page.value.id : null,
|
2022-06-20 03:38:49 -05:00
|
|
|
});
|
|
|
|
}
|
2019-07-06 16:56:13 -05:00
|
|
|
|
2023-12-06 23:42:09 -06:00
|
|
|
watch(() => path.value, fetchPage, { immediate: true });
|
2019-07-06 16:56:13 -05:00
|
|
|
|
2023-12-06 23:42:09 -06:00
|
|
|
const headerActions = computed(() => []);
|
2022-06-20 03:38:49 -05:00
|
|
|
|
2023-12-06 23:42:09 -06:00
|
|
|
const headerTabs = computed(() => []);
|
2022-06-20 03:38:49 -05:00
|
|
|
|
2024-02-16 01:17:09 -06:00
|
|
|
definePageMetadata(() => ({
|
|
|
|
title: page.value ? page.value.title || page.value.name : i18n.ts.pages,
|
|
|
|
...page.value ? {
|
|
|
|
avatar: page.value.user,
|
|
|
|
path: `/@${page.value.user.username}/pages/${page.value.name}`,
|
|
|
|
share: {
|
|
|
|
title: page.value.title || page.value.name,
|
|
|
|
text: page.value.summary,
|
|
|
|
},
|
|
|
|
} : {},
|
|
|
|
}));
|
2019-07-06 16:56:13 -05:00
|
|
|
</script>
|
2020-01-29 13:37:25 -06:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-25 01:14:26 -05:00
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
}
|
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
.xcukqgmh {
|
2020-10-17 06:12:00 -05:00
|
|
|
> .main {
|
2022-12-23 20:57:06 -06:00
|
|
|
padding: 32px;
|
2021-04-25 01:14:26 -05:00
|
|
|
|
2021-04-10 09:52:45 -05:00
|
|
|
> .header {
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
> h1 {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .banner {
|
2023-09-10 04:40:20 -05:00
|
|
|
> .thumbnail {
|
2021-04-25 01:14:26 -05:00
|
|
|
// TODO: 良い感じのアスペクト比で表示
|
2021-04-10 09:52:45 -05:00
|
|
|
display: block;
|
|
|
|
width: 100%;
|
2023-09-10 04:40:20 -05:00
|
|
|
height: auto;
|
|
|
|
aspect-ratio: 3/1;
|
|
|
|
border-radius: var(--radius);
|
|
|
|
overflow: hidden;
|
2021-04-10 09:52:45 -05:00
|
|
|
object-fit: cover;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .content {
|
2021-04-25 01:14:26 -05:00
|
|
|
margin-top: 16px;
|
|
|
|
padding: 16px 0 0 0;
|
2021-04-10 09:52:45 -05:00
|
|
|
}
|
|
|
|
|
2021-04-25 01:14:26 -05:00
|
|
|
> .actions {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
margin-top: 16px;
|
|
|
|
padding: 16px 0 0 0;
|
2021-04-10 09:52:45 -05:00
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
|
2021-04-25 01:14:26 -05:00
|
|
|
> .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;
|
|
|
|
}
|
2020-04-17 06:36:51 -05:00
|
|
|
}
|
|
|
|
|
2021-04-10 09:52:45 -05:00
|
|
|
> .links {
|
2021-04-25 01:14:26 -05:00
|
|
|
margin-top: 16px;
|
|
|
|
padding: 24px 0 0 0;
|
2021-04-10 09:52:45 -05:00
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
> .link {
|
|
|
|
margin-right: 0.75em;
|
2020-04-17 06:36:51 -05:00
|
|
|
}
|
2020-04-13 10:13:49 -05:00
|
|
|
}
|
2020-04-05 03:55:51 -05:00
|
|
|
}
|
2021-04-10 09:52:45 -05:00
|
|
|
|
|
|
|
> .footer {
|
2021-12-02 21:41:30 -06:00
|
|
|
margin: var(--margin) 0 var(--margin) 0;
|
2021-04-10 09:52:45 -05:00
|
|
|
font-size: 85%;
|
|
|
|
opacity: 0.75;
|
|
|
|
}
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
</style>
|
2023-09-10 04:40:20 -05:00
|
|
|
|
|
|
|
<style module>
|
|
|
|
.relatedPagesRoot {
|
|
|
|
padding: var(--margin);
|
|
|
|
}
|
|
|
|
|
|
|
|
.relatedPagesItem > article {
|
|
|
|
background-color: var(--panelHighlight) !important;
|
|
|
|
}
|
|
|
|
</style>
|