2019-07-07 06:56:13 +09:00
|
|
|
<template>
|
2020-10-17 20:12:00 +09:00
|
|
|
<div class="xcukqgmh" v-if="page" :key="page.id">
|
|
|
|
<div class="_section main">
|
|
|
|
<div class="_content">
|
|
|
|
<div class="banner">
|
|
|
|
<img :src="page.eyeCatchingImage.url" v-if="page.eyeCatchingImageId"/>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<XPage :page="page"/>
|
|
|
|
<small style="display: block; opacity: 0.7; margin-top: 1em;">@{{ page.user.username }}</small>
|
|
|
|
</div>
|
2020-04-14 00:13:49 +09:00
|
|
|
</div>
|
2020-10-17 20:12:00 +09:00
|
|
|
</div>
|
|
|
|
<div class="_section like">
|
2020-01-30 06:19:18 +09:00
|
|
|
<div class="_content">
|
2020-10-17 20:12:00 +09:00
|
|
|
<button class="_button" @click="unlike()" v-if="page.isLiked" :title="$t('_pages.unlike')"><Fa :icon="faHeartS"/></button>
|
|
|
|
<button class="_button" @click="like()" v-else :title="$t('_pages.like')"><Fa :icon="faHeartR"/></button>
|
|
|
|
<span class="count" v-if="page.likedCount > 0">{{ page.likedCount }}</span>
|
2020-01-30 06:19:18 +09:00
|
|
|
</div>
|
2020-10-17 20:12:00 +09:00
|
|
|
</div>
|
|
|
|
<div class="_section links">
|
|
|
|
<div class="_content">
|
2020-10-25 01:21:41 +09:00
|
|
|
<MkA :to="`./${page.name}/view-source`" class="link">{{ $t('_pages.viewSource') }}</MkA>
|
2020-12-19 10:55:52 +09:00
|
|
|
<template v-if="$i && $i.id === page.userId">
|
2020-11-17 14:59:15 +09:00
|
|
|
<MkA :to="`/pages/edit/${page.id}`" class="link">{{ $t('_pages.editThisPage') }}</MkA>
|
2020-12-19 10:55:52 +09:00
|
|
|
<button v-if="$i.pinnedPageId === page.id" @click="pin(false)" class="link _textButton">{{ $t('unpin') }}</button>
|
2020-10-17 20:12:00 +09:00
|
|
|
<button v-else @click="pin(true)" class="link _textButton">{{ $t('pin') }}</button>
|
2020-01-30 06:19:18 +09:00
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
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';
|
2020-02-19 04:15:14 +09:00
|
|
|
import { faHeart as faHeartS } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { faHeart as faHeartR } from '@fortawesome/free-regular-svg-icons';
|
2020-10-17 20:12:00 +09:00
|
|
|
import XPage from '@/components/page/page.vue';
|
|
|
|
import * as os from '@/os';
|
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: {
|
|
|
|
XPage
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
pageName: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
username: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2020-10-17 20:12:00 +09:00
|
|
|
INFO: computed(() => this.page ? {
|
2020-11-03 20:36:12 +09:00
|
|
|
title: computed(() => this.page.title || this.page.name),
|
|
|
|
avatar: this.page.user,
|
2020-10-17 20:12:00 +09:00
|
|
|
} : null),
|
2019-07-07 06:56:13 +09:00
|
|
|
page: null,
|
2020-02-19 04:15:14 +09:00
|
|
|
faHeartS, faHeartR
|
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() {
|
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;
|
|
|
|
});
|
|
|
|
},
|
2020-01-30 06:19:18 +09:00
|
|
|
|
|
|
|
like() {
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('pages/like', {
|
2020-01-30 06:19:18 +09:00
|
|
|
pageId: this.page.id,
|
|
|
|
}).then(() => {
|
|
|
|
this.page.isLiked = true;
|
|
|
|
this.page.likedCount++;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
unlike() {
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('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>
|
|
|
|
.xcukqgmh {
|
2020-10-17 20:12:00 +09:00
|
|
|
> .main {
|
|
|
|
> ._content {
|
|
|
|
> .banner {
|
|
|
|
> img {
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
height: 120px;
|
|
|
|
object-fit: cover;
|
|
|
|
}
|
2020-04-17 20:36:51 +09:00
|
|
|
}
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
}
|
2020-04-17 20:36:51 +09:00
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
> .links {
|
|
|
|
> ._content {
|
|
|
|
> .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
|
|
|
}
|
2020-01-30 04:37:25 +09:00
|
|
|
}
|
|
|
|
</style>
|