2019-07-07 06:56:13 +09:00
|
|
|
<template>
|
2021-04-25 15:14:26 +09:00
|
|
|
<div class="_root">
|
|
|
|
<transition name="fade" mode="out-in">
|
|
|
|
<div v-if="page" class="xcukqgmh" :key="page.id" v-size="{ max: [450] }">
|
|
|
|
<div class="_block main">
|
|
|
|
<!--
|
|
|
|
<div class="header">
|
|
|
|
<h1>{{ page.title }}</h1>
|
|
|
|
</div>
|
|
|
|
-->
|
|
|
|
<div class="banner">
|
|
|
|
<img :src="page.eyeCatchingImage.url" v-if="page.eyeCatchingImageId"/>
|
|
|
|
</div>
|
|
|
|
<div class="content">
|
|
|
|
<XPage :page="page"/>
|
|
|
|
</div>
|
|
|
|
<div class="actions">
|
|
|
|
<div class="like">
|
|
|
|
<MkButton class="button" @click="unlike()" v-if="page.isLiked" v-tooltip="$ts._pages.unlike" primary><i class="fas fa-heart"></i><span class="count" v-if="page.likedCount > 0">{{ page.likedCount }}</span></MkButton>
|
|
|
|
<MkButton class="button" @click="like()" v-else v-tooltip="$ts._pages.like"><i class="far fa-heart"></i><span class="count" v-if="page.likedCount > 0">{{ page.likedCount }}</span></MkButton>
|
|
|
|
</div>
|
|
|
|
<div class="other">
|
|
|
|
<button class="_button" @click="shareWithNote" v-tooltip="$ts.shareWithNote" v-click-anime><i class="fas fa-retweet fa-fw"></i></button>
|
|
|
|
<button class="_button" @click="share" v-tooltip="$ts.share" v-click-anime><i class="fas fa-share-alt fa-fw"></i></button>
|
|
|
|
</div>
|
|
|
|
</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" large class="koudoku"/>
|
|
|
|
</div>
|
|
|
|
<div class="links">
|
|
|
|
<MkA :to="`/@${username}/pages/${pageName}/view-source`" class="link">{{ $ts._pages.viewSource }}</MkA>
|
|
|
|
<template v-if="$i && $i.id === page.userId">
|
|
|
|
<MkA :to="`/pages/edit/${page.id}`" class="link">{{ $ts._pages.editThisPage }}</MkA>
|
|
|
|
<button v-if="$i.pinnedPageId === page.id" @click="pin(false)" class="link _textButton">{{ $ts.unpin }}</button>
|
|
|
|
<button v-else @click="pin(true)" class="link _textButton">{{ $ts.pin }}</button>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="footer">
|
|
|
|
<div><i class="far fa-clock"></i> {{ $ts.createdAt }}: <MkTime :time="page.createdAt" mode="detail"/></div>
|
|
|
|
<div v-if="page.createdAt != page.updatedAt"><i class="far fa-clock"></i> {{ $ts.updatedAt }}: <MkTime :time="page.updatedAt" mode="detail"/></div>
|
|
|
|
</div>
|
|
|
|
<MkContainer :max-height="300" :foldable="true" class="other">
|
|
|
|
<template #header><i class="fas fa-clock"></i> {{ $ts.recentPosts }}</template>
|
|
|
|
<MkPagination :pagination="otherPostsPagination" #default="{items}">
|
|
|
|
<MkPagePreview v-for="page in items" :page="page" :key="page.id" class="_gap"/>
|
|
|
|
</MkPagination>
|
|
|
|
</MkContainer>
|
2020-04-14 00:13:49 +09:00
|
|
|
</div>
|
2021-04-25 15:14:26 +09:00
|
|
|
<MkError v-else-if="error" @retry="fetch()"/>
|
|
|
|
<MkLoading v-else/>
|
|
|
|
</transition>
|
2020-01-30 04:37:25 +09:00
|
|
|
</div>
|
2019-07-07 06:56:13 +09:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 20:12:00 +09:00
|
|
|
import { computed, defineComponent } from 'vue';
|
2021-03-23 17:30:14 +09:00
|
|
|
import XPage from '@client/components/page/page.vue';
|
2021-04-10 23:52:45 +09:00
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
2021-03-23 17:30:14 +09:00
|
|
|
import * as os from '@client/os';
|
2021-04-10 12:54:12 +09:00
|
|
|
import * as symbols from '@client/symbols';
|
2021-04-25 15:14:26 +09:00
|
|
|
import { url } from '@client/config';
|
|
|
|
import MkFollowButton from '@client/components/follow-button.vue';
|
|
|
|
import MkContainer from '@client/components/ui/container.vue';
|
|
|
|
import MkPagination from '@client/components/ui/pagination.vue';
|
|
|
|
import MkPagePreview from '@client/components/page-preview.vue';
|
2019-07-07 06:56:13 +09:00
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
export default defineComponent({
|
2019-07-07 06:56:13 +09:00
|
|
|
components: {
|
2021-04-10 23:52:45 +09:00
|
|
|
XPage,
|
|
|
|
MkButton,
|
2021-04-25 15:14:26 +09:00
|
|
|
MkFollowButton,
|
|
|
|
MkContainer,
|
|
|
|
MkPagination,
|
|
|
|
MkPagePreview,
|
2019-07-07 06:56:13 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
pageName: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
username: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 12:54:12 +09:00
|
|
|
[symbols.PAGE_INFO]: computed(() => this.page ? {
|
2020-11-03 20:36:12 +09:00
|
|
|
title: computed(() => this.page.title || this.page.name),
|
|
|
|
avatar: this.page.user,
|
2021-04-10 23:52:45 +09:00
|
|
|
path: `/@${this.page.user.username}/pages/${this.page.name}`,
|
|
|
|
share: {
|
|
|
|
title: this.page.title || this.page.name,
|
|
|
|
text: this.page.summary,
|
|
|
|
},
|
2020-10-17 20:12:00 +09:00
|
|
|
} : null),
|
2019-07-07 06:56:13 +09:00
|
|
|
page: null,
|
2021-04-25 15:14:26 +09:00
|
|
|
error: null,
|
|
|
|
otherPostsPagination: {
|
|
|
|
endpoint: 'users/pages',
|
|
|
|
limit: 6,
|
|
|
|
params: () => ({
|
|
|
|
userId: this.page.user.id
|
|
|
|
})
|
|
|
|
},
|
2019-07-07 06:56:13 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
path(): string {
|
|
|
|
return this.username + '/' + this.pageName;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
path() {
|
|
|
|
this.fetch();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
2021-04-25 15:14:26 +09:00
|
|
|
this.page = null;
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('pages/show', {
|
2019-07-07 06:56:13 +09:00
|
|
|
name: this.pageName,
|
|
|
|
username: this.username,
|
|
|
|
}).then(page => {
|
|
|
|
this.page = page;
|
2021-04-25 15:14:26 +09:00
|
|
|
}).catch(e => {
|
|
|
|
this.error = e;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
share() {
|
|
|
|
navigator.share({
|
|
|
|
title: this.page.title || this.page.name,
|
|
|
|
text: this.page.summary,
|
|
|
|
url: `${url}/@${this.page.user.username}/pages/${this.page.name}`
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
shareWithNote() {
|
|
|
|
os.post({
|
|
|
|
initialText: `${this.page.title || this.page.name} ${url}/@${this.page.user.username}/pages/${this.page.name}`
|
2019-07-07 06:56:13 +09:00
|
|
|
});
|
|
|
|
},
|
2020-01-30 06:19:18 +09:00
|
|
|
|
|
|
|
like() {
|
2021-04-10 23:52:45 +09:00
|
|
|
os.apiWithDialog('pages/like', {
|
2020-01-30 06:19:18 +09:00
|
|
|
pageId: this.page.id,
|
|
|
|
}).then(() => {
|
|
|
|
this.page.isLiked = true;
|
|
|
|
this.page.likedCount++;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-04-10 23:52:45 +09:00
|
|
|
async unlike() {
|
|
|
|
const confirm = await os.dialog({
|
|
|
|
type: 'warning',
|
|
|
|
showCancelButton: true,
|
|
|
|
text: this.$ts.unlikeConfirm,
|
|
|
|
});
|
|
|
|
if (confirm.canceled) return;
|
|
|
|
os.apiWithDialog('pages/unlike', {
|
2020-01-30 06:19:18 +09:00
|
|
|
pageId: this.page.id,
|
|
|
|
}).then(() => {
|
|
|
|
this.page.isLiked = false;
|
|
|
|
this.page.likedCount--;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
pin(pin) {
|
2020-10-17 20:12:00 +09:00
|
|
|
os.apiWithDialog('i/update', {
|
2020-01-30 06:19:18 +09:00
|
|
|
pinnedPageId: pin ? this.page.id : null,
|
|
|
|
});
|
|
|
|
}
|
2019-07-07 06:56:13 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2020-01-30 04:37:25 +09:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-25 15:14:26 +09:00
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
}
|
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2020-01-30 04:37:25 +09:00
|
|
|
.xcukqgmh {
|
2021-04-10 23:52:45 +09:00
|
|
|
--padding: 32px;
|
|
|
|
|
|
|
|
&.max-width_450px {
|
|
|
|
--padding: 16px;
|
|
|
|
}
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
> .main {
|
2021-04-25 15:14:26 +09:00
|
|
|
padding: var(--padding);
|
|
|
|
|
2021-04-10 23:52:45 +09:00
|
|
|
> .header {
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
> h1 {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .banner {
|
|
|
|
> img {
|
2021-04-25 15:14:26 +09:00
|
|
|
// TODO: 良い感じのアスペクト比で表示
|
2021-04-10 23:52:45 +09:00
|
|
|
display: block;
|
|
|
|
width: 100%;
|
2021-04-25 15:14:26 +09:00
|
|
|
height: 150px;
|
2021-04-10 23:52:45 +09:00
|
|
|
object-fit: cover;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .content {
|
2021-04-25 15:14:26 +09:00
|
|
|
margin-top: 16px;
|
|
|
|
padding: 16px 0 0 0;
|
2021-04-10 23:52:45 +09:00
|
|
|
}
|
|
|
|
|
2021-04-25 15:14:26 +09:00
|
|
|
> .actions {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
margin-top: 16px;
|
|
|
|
padding: 16px 0 0 0;
|
2021-04-10 23:52:45 +09:00
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
|
2021-04-25 15:14:26 +09:00
|
|
|
> .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;
|
2021-04-10 23:52:45 +09:00
|
|
|
|
2021-04-25 15:14:26 +09:00
|
|
|
::v-deep(.count) {
|
|
|
|
margin-left: 0.5em;
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
}
|
2020-04-17 20:36:51 +09:00
|
|
|
}
|
2021-04-25 15:14:26 +09: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 20:36:51 +09:00
|
|
|
}
|
|
|
|
|
2021-04-10 23:52:45 +09:00
|
|
|
> .links {
|
2021-04-25 15:14:26 +09:00
|
|
|
margin-top: 16px;
|
|
|
|
padding: 24px 0 0 0;
|
2021-04-10 23:52:45 +09:00
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
> .link {
|
|
|
|
margin-right: 0.75em;
|
2020-04-17 20:36:51 +09:00
|
|
|
}
|
2020-04-14 00:13:49 +09:00
|
|
|
}
|
2020-04-05 17:55:51 +09:00
|
|
|
}
|
2021-04-10 23:52:45 +09:00
|
|
|
|
|
|
|
> .footer {
|
2021-04-14 02:12:46 +09:00
|
|
|
margin: var(--padding);
|
2021-04-10 23:52:45 +09:00
|
|
|
font-size: 85%;
|
|
|
|
opacity: 0.75;
|
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
</style>
|