This commit is contained in:
syuilo 2021-04-10 23:52:45 +09:00
parent 5087a5af21
commit f44517f4af
5 changed files with 98 additions and 40 deletions

View File

@ -687,6 +687,7 @@ textColor: "文字"
saveAs: "名前を付けて保存" saveAs: "名前を付けて保存"
advanced: "高度" advanced: "高度"
value: "値" value: "値"
createdAt: "作成日時"
updatedAt: "更新日時" updatedAt: "更新日時"
saveConfirm: "保存しますか?" saveConfirm: "保存しますか?"
deleteConfirm: "削除しますか?" deleteConfirm: "削除しますか?"
@ -712,6 +713,7 @@ showingPastTimeline: "過去のタイムラインを表示しています"
clear: "クリア" clear: "クリア"
markAllAsRead: "全て既読にする" markAllAsRead: "全て既読にする"
goBack: "戻る" goBack: "戻る"
unlikeConfirm: "いいね解除しますか?"
_email: _email:
_follow: _follow:

View File

@ -45,7 +45,6 @@ import MkRemoteCaution from '@client/components/remote-caution.vue';
import MkButton from '@client/components/ui/button.vue'; import MkButton from '@client/components/ui/button.vue';
import * as os from '@client/os'; import * as os from '@client/os';
import * as symbols from '@client/symbols'; import * as symbols from '@client/symbols';
import { url } from '@client/config';
export default defineComponent({ export default defineComponent({
components: { components: {
@ -66,10 +65,10 @@ export default defineComponent({
[symbols.PAGE_INFO]: computed(() => this.note ? { [symbols.PAGE_INFO]: computed(() => this.note ? {
title: this.$ts.note, title: this.$ts.note,
avatar: this.note.user, avatar: this.note.user,
path: `/notes/${this.note.id}`,
share: { share: {
title: this.$t('noteOf', { user: this.note.user.name }), title: this.$t('noteOf', { user: this.note.user.name }),
text: this.note.text, text: this.note.text,
url: `${url}/notes/${this.note.id}`
}, },
} : null), } : null),
note: null, note: null,

View File

@ -1,25 +1,23 @@
<template> <template>
<div class="xcukqgmh" v-if="page" :key="page.id"> <div class="xcukqgmh _root" v-if="page" :key="page.id" v-size="{ max: [450] }">
<div class="_section main"> <div class="_block main">
<div class="_content"> <!--
<div class="header">
<h1>{{ page.title }}</h1>
</div>
-->
<div class="banner"> <div class="banner">
<img :src="page.eyeCatchingImage.url" v-if="page.eyeCatchingImageId"/> <img :src="page.eyeCatchingImage.url" v-if="page.eyeCatchingImageId"/>
</div> </div>
<div> <div class="content">
<XPage :page="page"/> <XPage :page="page"/>
<small style="display: block; opacity: 0.7; margin-top: 1em;">@{{ page.user.username }}</small> <small style="display: block; opacity: 0.7; margin-top: 1em;">@{{ page.user.username }}</small>
</div> </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>
</div> <div class="links">
<div class="_section like">
<div class="_content">
<button class="_button" @click="unlike()" v-if="page.isLiked" :title="$ts._pages.unlike"><Fa :icon="faHeartS"/></button>
<button class="_button" @click="like()" v-else :title="$ts._pages.like"><Fa :icon="faHeartR"/></button>
<span class="count" v-if="page.likedCount > 0">{{ page.likedCount }}</span>
</div>
</div>
<div class="_section links">
<div class="_content">
<MkA :to="`/@${username}/pages/${pageName}/view-source`" class="link">{{ $ts._pages.viewSource }}</MkA> <MkA :to="`/@${username}/pages/${pageName}/view-source`" class="link">{{ $ts._pages.viewSource }}</MkA>
<template v-if="$i && $i.id === page.userId"> <template v-if="$i && $i.id === page.userId">
<MkA :to="`/pages/edit/${page.id}`" class="link">{{ $ts._pages.editThisPage }}</MkA> <MkA :to="`/pages/edit/${page.id}`" class="link">{{ $ts._pages.editThisPage }}</MkA>
@ -28,20 +26,26 @@
</template> </template>
</div> </div>
</div> </div>
<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>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { computed, defineComponent } from 'vue'; import { computed, defineComponent } from 'vue';
import { faHeart as faHeartS } from '@fortawesome/free-solid-svg-icons'; import { faHeart as faHeartS } from '@fortawesome/free-solid-svg-icons';
import { faHeart as faHeartR } from '@fortawesome/free-regular-svg-icons'; import { faHeart as faHeartR, faClock } from '@fortawesome/free-regular-svg-icons';
import XPage from '@client/components/page/page.vue'; import XPage from '@client/components/page/page.vue';
import MkButton from '@client/components/ui/button.vue';
import * as os from '@client/os'; import * as os from '@client/os';
import * as symbols from '@client/symbols'; import * as symbols from '@client/symbols';
export default defineComponent({ export default defineComponent({
components: { components: {
XPage XPage,
MkButton,
}, },
props: { props: {
@ -60,9 +64,14 @@ export default defineComponent({
[symbols.PAGE_INFO]: computed(() => this.page ? { [symbols.PAGE_INFO]: computed(() => this.page ? {
title: computed(() => this.page.title || this.page.name), title: computed(() => this.page.title || this.page.name),
avatar: this.page.user, avatar: this.page.user,
path: `/@${this.page.user.username}/pages/${this.page.name}`,
share: {
title: this.page.title || this.page.name,
text: this.page.summary,
},
} : null), } : null),
page: null, page: null,
faHeartS, faHeartR faHeartS, faHeartR, faClock,
}; };
}, },
@ -93,7 +102,7 @@ export default defineComponent({
}, },
like() { like() {
os.api('pages/like', { os.apiWithDialog('pages/like', {
pageId: this.page.id, pageId: this.page.id,
}).then(() => { }).then(() => {
this.page.isLiked = true; this.page.isLiked = true;
@ -101,8 +110,14 @@ export default defineComponent({
}); });
}, },
unlike() { async unlike() {
os.api('pages/unlike', { const confirm = await os.dialog({
type: 'warning',
showCancelButton: true,
text: this.$ts.unlikeConfirm,
});
if (confirm.canceled) return;
os.apiWithDialog('pages/unlike', {
pageId: this.page.id, pageId: this.page.id,
}).then(() => { }).then(() => {
this.page.isLiked = false; this.page.isLiked = false;
@ -121,8 +136,21 @@ export default defineComponent({
<style lang="scss" scoped> <style lang="scss" scoped>
.xcukqgmh { .xcukqgmh {
--padding: 32px;
&.max-width_450px {
--padding: 16px;
}
> .main { > .main {
> ._content { > .header {
padding: 16px;
> h1 {
margin: 0;
}
}
> .banner { > .banner {
> img { > img {
display: block; display: block;
@ -131,15 +159,41 @@ export default defineComponent({
object-fit: cover; 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;
}
} }
} }
> .links { > .links {
> ._content { padding: var(--padding);
border-top: solid 0.5px var(--divider);
> .link { > .link {
margin-right: 0.75em; margin-right: 0.75em;
} }
} }
} }
> .footer {
padding: var(--padding);
font-size: 85%;
opacity: 0.75;
}
} }
</style> </style>

View File

@ -238,7 +238,6 @@ import { getUserMenu } from '@client/scripts/get-user-menu';
import number from '../../filters/number'; import number from '../../filters/number';
import { userPage, acct as getAcct } from '../../filters/user'; import { userPage, acct as getAcct } from '../../filters/user';
import * as os from '@client/os'; import * as os from '@client/os';
import { url } from '@client/config';
import * as symbols from '@client/symbols'; import * as symbols from '@client/symbols';
export default defineComponent({ export default defineComponent({
@ -274,9 +273,9 @@ export default defineComponent({
[symbols.PAGE_INFO]: computed(() => this.user ? { [symbols.PAGE_INFO]: computed(() => this.user ? {
userName: this.user, userName: this.user,
avatar: this.user, avatar: this.user,
path: `/@${this.user.username}`,
share: { share: {
title: this.user.name, title: this.user.name,
url: `${url}/@${this.user.username}`
}, },
} : null), } : null),
user: null, user: null,

View File

@ -26,6 +26,7 @@
import { defineComponent } from 'vue'; import { defineComponent } from 'vue';
import { faChevronLeft, faCircle, faShareAlt, faEllipsisH } from '@fortawesome/free-solid-svg-icons'; import { faChevronLeft, faCircle, faShareAlt, faEllipsisH } from '@fortawesome/free-solid-svg-icons';
import { modalMenu } from '@client/os'; import { modalMenu } from '@client/os';
import { url } from '@client/config';
export default defineComponent({ export default defineComponent({
props: { props: {
@ -86,7 +87,10 @@ export default defineComponent({
}, },
share() { share() {
navigator.share(this.info.share); navigator.share({
url: url + this.info.path,
...this.info.share,
});
}, },
menu(ev) { menu(ev) {