2022-06-21 07:12:39 +02:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header
|
|
|
|
><MkPageHeader
|
|
|
|
:actions="headerActions"
|
|
|
|
:tabs="headerTabs"
|
|
|
|
:display-back-button="true"
|
|
|
|
/></template>
|
|
|
|
<MkSpacer :content-max="800">
|
|
|
|
<transition
|
|
|
|
:name="$store.state.animation ? 'fade' : ''"
|
|
|
|
mode="out-in"
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
v-if="page"
|
|
|
|
:key="page.id"
|
|
|
|
v-size="{ max: [450] }"
|
|
|
|
class="xcukqgmh"
|
|
|
|
>
|
|
|
|
<div class="footer">
|
|
|
|
<div>
|
|
|
|
<i class="ph-alarm ph-bold" />
|
|
|
|
{{ i18n.ts.createdAt }}:
|
|
|
|
<MkTime :time="page.createdAt" mode="detail" />
|
|
|
|
</div>
|
|
|
|
<div v-if="page.createdAt != page.updatedAt">
|
|
|
|
<i class="ph-alarm ph-bold"></i>
|
|
|
|
{{ i18n.ts.updatedAt }}:
|
|
|
|
<MkTime :time="page.updatedAt" mode="detail" />
|
2022-11-21 23:55:41 +01:00
|
|
|
</div>
|
2021-10-14 11:51:15 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="_block main">
|
|
|
|
<div class="banner">
|
|
|
|
<div class="banner-image">
|
|
|
|
<div class="header">
|
|
|
|
<h1>{{ page.title }}</h1>
|
|
|
|
</div>
|
|
|
|
<div class="menu-actions">
|
|
|
|
<button
|
|
|
|
v-tooltip="i18n.ts.copyUrl"
|
|
|
|
@click="copyUrl"
|
|
|
|
class="menu _button"
|
|
|
|
>
|
|
|
|
<i
|
|
|
|
class="ph-link-simple ph-bold ph-lg"
|
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
<MkA
|
|
|
|
v-tooltip="i18n.ts._pages.viewSource"
|
|
|
|
:to="`/@${username}/pages/${pageName}/view-source`"
|
|
|
|
class="menu _button"
|
|
|
|
style="transform: translateY(2px)"
|
|
|
|
><i class="ph-code ph-bold ph-lg"
|
|
|
|
/></MkA>
|
|
|
|
<template
|
|
|
|
v-if="$i && $i.id === page.userId"
|
|
|
|
>
|
|
|
|
<MkA
|
|
|
|
v-tooltip="i18n.ts._pages.editPage"
|
|
|
|
class="menu _button"
|
|
|
|
:to="`/pages/edit/${page.id}`"
|
|
|
|
style="transform: translateY(2px)"
|
|
|
|
><i class="ph-pencil ph-bold ph-lg"
|
|
|
|
/></MkA>
|
|
|
|
<button
|
|
|
|
v-if="$i.pinnedPageId === page.id"
|
|
|
|
v-tooltip="i18n.ts.unpin"
|
|
|
|
class="menu _button"
|
|
|
|
@click="pin(false)"
|
|
|
|
>
|
|
|
|
<i
|
|
|
|
class="ph-push-pin-slash ph-bold ph-lg"
|
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
v-else
|
|
|
|
v-tooltip="i18n.ts.pin"
|
|
|
|
class="menu _button"
|
|
|
|
@click="pin(true)"
|
|
|
|
>
|
|
|
|
<i
|
|
|
|
class="ph-push-pin ph-bold ph-lg"
|
|
|
|
/>
|
|
|
|
</button>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-21 07:12:39 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="content">
|
|
|
|
<XPage :page="page" />
|
2022-06-21 07:12:39 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div class="actions">
|
|
|
|
<div class="like">
|
|
|
|
<MkButton
|
|
|
|
v-if="page.isLiked"
|
|
|
|
v-tooltip="i18n.ts._pages.unlike"
|
|
|
|
class="button"
|
|
|
|
primary
|
|
|
|
@click="unlike()"
|
|
|
|
><i class="ph-heart ph-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 ph-bold"></i
|
|
|
|
><span
|
|
|
|
v-if="page.likedCount > 0"
|
|
|
|
class="count"
|
|
|
|
>{{ page.likedCount }}</span
|
|
|
|
></MkButton
|
|
|
|
>
|
|
|
|
</div>
|
|
|
|
<div class="other">
|
|
|
|
<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 class="user">
|
|
|
|
<MkAvatar :user="page.user" class="avatar" />
|
|
|
|
<div class="name">
|
|
|
|
<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-11-19 02:54:50 +01:00
|
|
|
</div>
|
2022-06-21 07:12:39 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<!-- <div class="links">
|
2022-07-20 15:24:26 +02:00
|
|
|
<MkA :to="`/@${username}/pages/${pageName}/view-source`" class="link">{{ i18n.ts._pages.viewSource }}</MkA>
|
2022-06-21 07:12:39 +02:00
|
|
|
<template v-if="$i && $i.id === page.userId">
|
2022-07-20 15:24:26 +02: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 07:12:39 +02:00
|
|
|
</template>
|
2022-11-21 23:55:41 +01:00
|
|
|
</div> -->
|
2023-04-08 02:01:42 +02:00
|
|
|
</div>
|
|
|
|
<MkAd :prefer="['horizontal', 'horizontal-big']" />
|
|
|
|
<MkContainer
|
|
|
|
:max-height="300"
|
|
|
|
:foldable="true"
|
|
|
|
:expanded="false"
|
|
|
|
class="other"
|
|
|
|
>
|
|
|
|
<template #header
|
|
|
|
><i class="ph-clock ph-bold ph-lg"></i>
|
|
|
|
{{ i18n.ts.recentPosts }}</template
|
|
|
|
>
|
|
|
|
<MkPagination
|
|
|
|
v-slot="{ items }"
|
|
|
|
:pagination="otherPostsPagination"
|
|
|
|
>
|
|
|
|
<MkPagePreview
|
|
|
|
v-for="page in items"
|
|
|
|
:key="page.id"
|
|
|
|
:page="page"
|
|
|
|
class="_gap"
|
|
|
|
/>
|
|
|
|
</MkPagination>
|
|
|
|
</MkContainer>
|
2021-04-25 08:14:26 +02:00
|
|
|
</div>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkError v-else-if="error" @retry="fetchPage()" />
|
|
|
|
<MkLoading v-else />
|
|
|
|
</transition>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2019-07-06 23:56:13 +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, watch } from "vue";
|
|
|
|
import XPage from "@/components/page/page.vue";
|
|
|
|
import MkButton from "@/components/MkButton.vue";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { url } from "@/config";
|
|
|
|
import MkFollowButton from "@/components/MkFollowButton.vue";
|
|
|
|
import MkContainer from "@/components/MkContainer.vue";
|
|
|
|
import MkPagination from "@/components/MkPagination.vue";
|
|
|
|
import MkPagePreview from "@/components/MkPagePreview.vue";
|
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
import copyToClipboard from "@/scripts/copy-to-clipboard";
|
|
|
|
import { definePageMetadata } from "@/scripts/page-metadata";
|
|
|
|
import { shareAvailable } from "@/scripts/share-available";
|
2022-06-20 10:38:49 +02:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
pageName: string;
|
|
|
|
username: string;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
let page = $ref(null);
|
2022-11-22 06:27:39 +01:00
|
|
|
let bgImg = $ref(null);
|
2022-06-20 10:38:49 +02:00
|
|
|
let error = $ref(null);
|
|
|
|
const otherPostsPagination = {
|
2023-04-08 02:01:42 +02:00
|
|
|
endpoint: "users/pages" as const,
|
2022-06-20 10:38:49 +02:00
|
|
|
limit: 6,
|
|
|
|
params: computed(() => ({
|
|
|
|
userId: page.user.id,
|
|
|
|
})),
|
|
|
|
};
|
2023-04-08 02:01:42 +02:00
|
|
|
const path = $computed(() => props.username + "/" + props.pageName);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
|
|
|
function fetchPage() {
|
|
|
|
page = null;
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("pages/show", {
|
2022-06-20 10:38:49 +02:00
|
|
|
name: props.pageName,
|
|
|
|
username: props.username,
|
2023-04-08 02:01:42 +02:00
|
|
|
})
|
|
|
|
.then((_page) => {
|
|
|
|
page = _page;
|
|
|
|
bgImg = getBgImg();
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
error = err;
|
|
|
|
});
|
2022-06-20 10:38:49 +02:00
|
|
|
}
|
2019-07-06 23:56:13 +02:00
|
|
|
|
2022-12-06 08:44:41 +01:00
|
|
|
function copyUrl() {
|
|
|
|
copyToClipboard(window.location.href);
|
|
|
|
os.success();
|
|
|
|
}
|
|
|
|
|
2022-11-22 06:27:39 +01:00
|
|
|
function getBgImg(): string {
|
2022-11-22 06:08:03 +01:00
|
|
|
if (page.eyeCatchingImage != null) {
|
2022-11-22 06:27:39 +01:00
|
|
|
return `url(${page.eyeCatchingImage.url})`;
|
2023-04-08 02:01:42 +02:00
|
|
|
} else {
|
|
|
|
return "linear-gradient(to bottom right, #31748f, #9ccfd8)";
|
2022-11-22 06:08:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
function share() {
|
|
|
|
navigator.share({
|
|
|
|
title: page.title ?? page.name,
|
|
|
|
text: page.summary,
|
|
|
|
url: `${url}/@${page.user.username}/pages/${page.name}`,
|
|
|
|
});
|
|
|
|
}
|
2019-07-06 23:56:13 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
function shareWithNote() {
|
|
|
|
os.post({
|
2023-04-08 02:01:42 +02:00
|
|
|
initialText: `${page.title || page.name} ${url}/@${
|
|
|
|
page.user.username
|
|
|
|
}/pages/${page.name}`,
|
2022-06-20 10:38:49 +02:00
|
|
|
});
|
|
|
|
}
|
2019-07-06 23:56:13 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
function like() {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("pages/like", {
|
2022-06-20 10:38:49 +02:00
|
|
|
pageId: page.id,
|
|
|
|
}).then(() => {
|
|
|
|
page.isLiked = true;
|
|
|
|
page.likedCount++;
|
|
|
|
});
|
|
|
|
}
|
2019-07-06 23:56:13 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
async function unlike() {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.api("pages/unlike", {
|
2022-06-20 10:38:49 +02:00
|
|
|
pageId: page.id,
|
|
|
|
}).then(() => {
|
|
|
|
page.isLiked = false;
|
|
|
|
page.likedCount--;
|
|
|
|
});
|
|
|
|
}
|
2019-07-06 23:56:13 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
function pin(pin) {
|
2023-04-08 02:01:42 +02:00
|
|
|
os.apiWithDialog("i/update", {
|
2022-06-20 10:38:49 +02:00
|
|
|
pinnedPageId: pin ? page.id : null,
|
|
|
|
});
|
|
|
|
}
|
2019-07-06 23:56:13 +02:00
|
|
|
|
2022-11-22 06:08:03 +01:00
|
|
|
watch(() => path, fetchPage, { immediate: true });
|
2019-07-06 23:56:13 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const headerActions = $computed(() => []);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
2023-04-08 02:01:42 +02:00
|
|
|
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 23:56:13 +02:00
|
|
|
</script>
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-25 08:14:26 +02:00
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
}
|
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
.xcukqgmh {
|
2020-10-17 13:12:00 +02:00
|
|
|
> .main {
|
2022-11-16 10:00:20 +01:00
|
|
|
> * {
|
|
|
|
margin: 1rem;
|
|
|
|
}
|
2021-04-25 08:14:26 +02:00
|
|
|
|
2021-04-10 16:52:45 +02:00
|
|
|
> .banner {
|
2022-11-16 10:15:19 +01:00
|
|
|
margin: 0rem !important;
|
|
|
|
|
2022-11-21 23:55:41 +01:00
|
|
|
> .banner-image {
|
2021-04-25 08:14:26 +02:00
|
|
|
// TODO: 良い感じのアスペクト比で表示
|
2021-04-10 16:52:45 +02:00
|
|
|
display: block;
|
|
|
|
width: 100%;
|
2021-04-25 08:14:26 +02:00
|
|
|
height: 150px;
|
2022-11-22 00:03:35 +01:00
|
|
|
background-position: center;
|
|
|
|
background-size: cover;
|
2023-04-08 02:01:42 +02:00
|
|
|
background-image: v-bind("bgImg");
|
2022-11-22 00:03:35 +01:00
|
|
|
|
2022-11-22 01:27:32 +01:00
|
|
|
> .header {
|
|
|
|
padding: 16px;
|
2022-11-22 00:03:35 +01:00
|
|
|
|
2022-11-22 01:27:32 +01:00
|
|
|
> h1 {
|
|
|
|
margin: 0;
|
|
|
|
color: white;
|
2023-01-04 03:56:43 +01:00
|
|
|
text-shadow: 0 0 8px var(--shadow);
|
2022-11-22 01:27:32 +01:00
|
|
|
}
|
2022-11-22 00:03:35 +01:00
|
|
|
}
|
2022-11-21 23:55:41 +01:00
|
|
|
|
2022-11-22 01:27:32 +01:00
|
|
|
> .menu-actions {
|
|
|
|
-webkit-backdrop-filter: var(--blur, blur(8px));
|
|
|
|
backdrop-filter: var(--blur, blur(8px));
|
|
|
|
background: rgba(0, 0, 0, 0.2);
|
|
|
|
padding: 8px;
|
|
|
|
border-radius: 24px;
|
|
|
|
width: fit-content;
|
|
|
|
position: relative;
|
|
|
|
top: -10px;
|
|
|
|
left: 1rem;
|
|
|
|
|
|
|
|
> .menu {
|
|
|
|
vertical-align: bottom;
|
|
|
|
height: 31px;
|
|
|
|
width: 31px;
|
|
|
|
color: #fff;
|
2023-01-04 03:56:43 +01:00
|
|
|
text-shadow: 0 0 8px var(--shadow);
|
2022-11-22 01:27:32 +01:00
|
|
|
font-size: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .koudoku {
|
|
|
|
margin-left: 4px;
|
|
|
|
vertical-align: bottom;
|
|
|
|
}
|
2022-11-21 23:55:41 +01:00
|
|
|
}
|
2021-04-10 16:52:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .content {
|
2022-11-23 06:58:09 +01:00
|
|
|
padding: 16px 0;
|
2021-04-10 16:52:45 +02:00
|
|
|
}
|
|
|
|
|
2021-04-25 08:14:26 +02:00
|
|
|
> .actions {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
margin-top: 16px;
|
2022-11-23 07:30:18 +01:00
|
|
|
padding: 16px 0;
|
2021-04-10 16:52:45 +02:00
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
|
2021-04-25 08:14:26 +02:00
|
|
|
> .like {
|
|
|
|
> .button {
|
2022-11-16 10:07:13 +01:00
|
|
|
--accent: #eb6f92;
|
|
|
|
--X8: #eb6f92;
|
2021-04-25 08:14:26 +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-10 16:52:45 +02:00
|
|
|
|
2021-04-25 08:14:26 +02:00
|
|
|
::v-deep(.count) {
|
|
|
|
margin-left: 0.5em;
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
}
|
2020-04-17 13:36:51 +02:00
|
|
|
}
|
2021-04-25 08:14:26 +02:00
|
|
|
|
|
|
|
> .other {
|
|
|
|
> button {
|
2022-11-22 05:33:29 +01:00
|
|
|
padding: 2px;
|
2021-04-25 08:14:26 +02:00
|
|
|
margin: 0 8px;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
color: var(--fgHighlighted);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-19 02:54:50 +01:00
|
|
|
> .user {
|
|
|
|
margin-left: auto;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
> .avatar {
|
2022-11-23 06:58:09 +01:00
|
|
|
width: 40px;
|
|
|
|
height: 40px;
|
2022-11-19 02:54:50 +01:00
|
|
|
}
|
2021-04-25 08:14:26 +02:00
|
|
|
|
2022-11-19 02:54:50 +01:00
|
|
|
> .name {
|
|
|
|
margin: 0 0 0 12px;
|
|
|
|
font-size: 90%;
|
|
|
|
}
|
2021-04-25 08:14:26 +02:00
|
|
|
|
2022-11-19 02:54:50 +01:00
|
|
|
> .koudoku {
|
|
|
|
margin-left: auto;
|
2022-11-19 02:58:22 +01:00
|
|
|
margin: 1rem;
|
2022-11-19 02:54:50 +01:00
|
|
|
}
|
2021-04-25 08:14:26 +02:00
|
|
|
}
|
2020-04-17 13:36:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-10 16:52:45 +02:00
|
|
|
> .links {
|
2021-04-25 08:14:26 +02:00
|
|
|
margin-top: 16px;
|
2022-11-16 10:12:24 +01:00
|
|
|
padding: 14px 0;
|
2021-04-10 16:52:45 +02:00
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
> .link {
|
2022-11-16 10:12:24 +01:00
|
|
|
margin-right: 2em;
|
2020-04-17 13:36:51 +02:00
|
|
|
}
|
2020-04-13 17:13:49 +02:00
|
|
|
}
|
2020-04-05 10:55:51 +02:00
|
|
|
}
|
2021-04-10 16:52:45 +02:00
|
|
|
|
|
|
|
> .footer {
|
2022-11-16 10:12:24 +01:00
|
|
|
margin: var(--margin) 0 var(--margin) 0;
|
2021-04-10 16:52:45 +02:00
|
|
|
font-size: 85%;
|
|
|
|
opacity: 0.75;
|
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
</style>
|