2019-07-06 21:56:13 +00:00
|
|
|
<template>
|
2021-04-10 14:52:45 +00:00
|
|
|
<div class="xcukqgmh _root" v-if="page" :key="page.id" v-size="{ max: [450] }">
|
|
|
|
<div class="_block main">
|
|
|
|
<!--
|
|
|
|
<div class="header">
|
|
|
|
<h1>{{ page.title }}</h1>
|
2020-04-13 15:13:49 +00:00
|
|
|
</div>
|
2021-04-10 14:52:45 +00:00
|
|
|
-->
|
|
|
|
<div class="banner">
|
|
|
|
<img :src="page.eyeCatchingImage.url" v-if="page.eyeCatchingImageId"/>
|
2020-01-29 21:19:18 +00:00
|
|
|
</div>
|
2021-04-10 14:52:45 +00:00
|
|
|
<div class="content">
|
|
|
|
<XPage :page="page"/>
|
|
|
|
<small style="display: block; opacity: 0.7; margin-top: 1em;">@{{ page.user.username }}</small>
|
|
|
|
</div>
|
|
|
|
<div class="like">
|
|
|
|
<MkButton class="button" @click="unlike()" v-if="page.isLiked" v-tooltip="$ts._pages.unlike" primary><Fa :icon="faHeartS"/><span class="count" v-if="page.likedCount > 0">{{ page.likedCount }}</span></MkButton>
|
|
|
|
<MkButton class="button" @click="like()" v-else v-tooltip="$ts._pages.like"><Fa :icon="faHeartR"/><span class="count" v-if="page.likedCount > 0">{{ page.likedCount }}</span></MkButton>
|
|
|
|
</div>
|
|
|
|
<div class="links">
|
2021-01-30 05:03:11 +00:00
|
|
|
<MkA :to="`/@${username}/pages/${pageName}/view-source`" class="link">{{ $ts._pages.viewSource }}</MkA>
|
2020-12-19 01:55:52 +00:00
|
|
|
<template v-if="$i && $i.id === page.userId">
|
2020-12-26 01:47:36 +00:00
|
|
|
<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>
|
2020-01-29 21:19:18 +00:00
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-10 14:52:45 +00:00
|
|
|
<div class="footer">
|
|
|
|
<div><Fa :icon="faClock"/> {{ $ts.createdAt }}: <MkTime :time="page.createdAt" mode="detail"/></div>
|
|
|
|
<div v-if="page.createdAt != page.updatedAt"><Fa :icon="faClock"/> {{ $ts.updatedAt }}: <MkTime :time="page.updatedAt" mode="detail"/></div>
|
|
|
|
</div>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
2019-07-06 21:56:13 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { computed, defineComponent } from 'vue';
|
2020-02-18 19:15:14 +00:00
|
|
|
import { faHeart as faHeartS } from '@fortawesome/free-solid-svg-icons';
|
2021-04-10 14:52:45 +00:00
|
|
|
import { faHeart as faHeartR, faClock } from '@fortawesome/free-regular-svg-icons';
|
2021-03-23 08:30:14 +00:00
|
|
|
import XPage from '@client/components/page/page.vue';
|
2021-04-10 14:52:45 +00:00
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
2021-03-23 08:30:14 +00:00
|
|
|
import * as os from '@client/os';
|
2021-04-10 03:54:12 +00:00
|
|
|
import * as symbols from '@client/symbols';
|
2019-07-06 21:56:13 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2019-07-06 21:56:13 +00:00
|
|
|
components: {
|
2021-04-10 14:52:45 +00:00
|
|
|
XPage,
|
|
|
|
MkButton,
|
2019-07-06 21:56:13 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
pageName: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
username: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 03:54:12 +00:00
|
|
|
[symbols.PAGE_INFO]: computed(() => this.page ? {
|
2020-11-03 11:36:12 +00:00
|
|
|
title: computed(() => this.page.title || this.page.name),
|
|
|
|
avatar: this.page.user,
|
2021-04-10 14:52:45 +00: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 11:12:00 +00:00
|
|
|
} : null),
|
2019-07-06 21:56:13 +00:00
|
|
|
page: null,
|
2021-04-10 14:52:45 +00:00
|
|
|
faHeartS, faHeartR, faClock,
|
2019-07-06 21:56:13 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
path(): string {
|
|
|
|
return this.username + '/' + this.pageName;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
path() {
|
|
|
|
this.fetch();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api('pages/show', {
|
2019-07-06 21:56:13 +00:00
|
|
|
name: this.pageName,
|
|
|
|
username: this.username,
|
|
|
|
}).then(page => {
|
|
|
|
this.page = page;
|
|
|
|
});
|
|
|
|
},
|
2020-01-29 21:19:18 +00:00
|
|
|
|
|
|
|
like() {
|
2021-04-10 14:52:45 +00:00
|
|
|
os.apiWithDialog('pages/like', {
|
2020-01-29 21:19:18 +00:00
|
|
|
pageId: this.page.id,
|
|
|
|
}).then(() => {
|
|
|
|
this.page.isLiked = true;
|
|
|
|
this.page.likedCount++;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-04-10 14:52:45 +00: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-29 21:19:18 +00:00
|
|
|
pageId: this.page.id,
|
|
|
|
}).then(() => {
|
|
|
|
this.page.isLiked = false;
|
|
|
|
this.page.likedCount--;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
pin(pin) {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.apiWithDialog('i/update', {
|
2020-01-29 21:19:18 +00:00
|
|
|
pinnedPageId: pin ? this.page.id : null,
|
|
|
|
});
|
|
|
|
}
|
2019-07-06 21:56:13 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2020-01-29 19:37:25 +00:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.xcukqgmh {
|
2021-04-10 14:52:45 +00:00
|
|
|
--padding: 32px;
|
|
|
|
|
|
|
|
&.max-width_450px {
|
|
|
|
--padding: 16px;
|
|
|
|
}
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
> .main {
|
2021-04-10 14:52:45 +00:00
|
|
|
> .header {
|
|
|
|
padding: 16px;
|
|
|
|
|
|
|
|
> h1 {
|
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .banner {
|
|
|
|
> img {
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
height: 120px;
|
|
|
|
object-fit: cover;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .content {
|
|
|
|
padding: var(--padding);
|
|
|
|
}
|
|
|
|
|
|
|
|
> .like {
|
|
|
|
padding: var(--padding);
|
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
|
|
|
|
> .button {
|
|
|
|
--accent: rgb(216 71 106);
|
|
|
|
--X8: rgb(241 92 128);
|
|
|
|
--buttonBg: rgb(216 71 106 / 5%);
|
|
|
|
--buttonHoverBg: rgb(216 71 106 / 10%);
|
|
|
|
|
|
|
|
::v-deep(.count) {
|
|
|
|
margin-left: 0.5em;
|
2020-10-17 11:12:00 +00:00
|
|
|
}
|
2020-04-17 11:36:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-10 14:52:45 +00:00
|
|
|
> .links {
|
|
|
|
padding: var(--padding);
|
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
> .link {
|
|
|
|
margin-right: 0.75em;
|
2020-04-17 11:36:51 +00:00
|
|
|
}
|
2020-04-13 15:13:49 +00:00
|
|
|
}
|
2020-04-05 08:55:51 +00:00
|
|
|
}
|
2021-04-10 14:52:45 +00:00
|
|
|
|
|
|
|
> .footer {
|
|
|
|
padding: var(--padding);
|
|
|
|
font-size: 85%;
|
|
|
|
opacity: 0.75;
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
</style>
|