2020-01-30 04:37:25 +09:00
|
|
|
<template>
|
2021-10-23 23:22:20 +09:00
|
|
|
<MkSpacer :content-max="800">
|
|
|
|
<div class="fcuexfpr">
|
2022-01-25 23:18:21 +09:00
|
|
|
<transition :name="$store.state.animation ? 'fade' : ''" mode="out-in">
|
2021-09-17 22:39:15 +09:00
|
|
|
<div v-if="note" class="note">
|
2021-11-19 19:36:12 +09:00
|
|
|
<div v-if="showNext" class="_gap">
|
2021-09-17 22:39:15 +09:00
|
|
|
<XNotes class="_content" :pagination="next" :no-gap="true"/>
|
2021-04-17 11:40:47 +09:00
|
|
|
</div>
|
2021-09-17 22:39:15 +09:00
|
|
|
|
|
|
|
<div class="main _gap">
|
|
|
|
<MkButton v-if="!showNext && hasNext" class="load next" @click="showNext = true"><i class="fas fa-chevron-up"></i></MkButton>
|
|
|
|
<div class="note _gap">
|
2022-02-25 20:03:17 +09:00
|
|
|
<MkRemoteCaution v-if="note.user.host != null" :href="note.url ?? note.uri" class="_isolated"/>
|
2021-11-19 19:36:12 +09:00
|
|
|
<XNoteDetailed :key="note.id" v-model:note="note" class="_isolated note"/>
|
2021-09-17 22:39:15 +09:00
|
|
|
</div>
|
2021-11-19 19:36:12 +09:00
|
|
|
<div v-if="clips && clips.length > 0" class="_content clips _gap">
|
2021-09-17 22:39:15 +09:00
|
|
|
<div class="title">{{ $ts.clip }}</div>
|
|
|
|
<MkA v-for="item in clips" :key="item.id" :to="`/clips/${item.id}`" class="item _panel _gap">
|
|
|
|
<b>{{ item.name }}</b>
|
|
|
|
<div v-if="item.description" class="description">{{ item.description }}</div>
|
|
|
|
<div class="user">
|
|
|
|
<MkAvatar :user="item.user" class="avatar" :show-indicator="true"/> <MkUserName :user="item.user" :nowrap="false"/>
|
|
|
|
</div>
|
|
|
|
</MkA>
|
|
|
|
</div>
|
|
|
|
<MkButton v-if="!showPrev && hasPrev" class="load prev" @click="showPrev = true"><i class="fas fa-chevron-down"></i></MkButton>
|
2021-04-17 11:40:47 +09:00
|
|
|
</div>
|
2020-02-16 22:15:49 +09:00
|
|
|
|
2021-11-19 19:36:12 +09:00
|
|
|
<div v-if="showPrev" class="_gap">
|
2021-09-17 22:39:15 +09:00
|
|
|
<XNotes class="_content" :pagination="prev" :no-gap="true"/>
|
|
|
|
</div>
|
2021-04-17 11:40:47 +09:00
|
|
|
</div>
|
2021-09-17 22:39:15 +09:00
|
|
|
<MkError v-else-if="error" @retry="fetch()"/>
|
|
|
|
<MkLoading v-else/>
|
|
|
|
</transition>
|
|
|
|
</div>
|
2021-10-23 23:22:20 +09:00
|
|
|
</MkSpacer>
|
2020-01-30 04:37:25 +09:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 20:12:00 +09:00
|
|
|
import { computed, defineComponent } from 'vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import XNote from '@/components/note.vue';
|
|
|
|
import XNoteDetailed from '@/components/note-detailed.vue';
|
|
|
|
import XNotes from '@/components/notes.vue';
|
|
|
|
import MkRemoteCaution from '@/components/remote-caution.vue';
|
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import * as symbols from '@/symbols';
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
export default defineComponent({
|
2020-01-30 04:37:25 +09:00
|
|
|
components: {
|
2020-02-16 22:15:49 +09:00
|
|
|
XNote,
|
2021-01-01 22:41:20 +09:00
|
|
|
XNoteDetailed,
|
2020-02-16 22:15:49 +09:00
|
|
|
XNotes,
|
2020-03-21 13:07:02 +09:00
|
|
|
MkRemoteCaution,
|
2020-10-17 20:12:00 +09:00
|
|
|
MkButton,
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
2020-10-25 01:21:41 +09:00
|
|
|
props: {
|
|
|
|
noteId: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 12:54:12 +09:00
|
|
|
[symbols.PAGE_INFO]: computed(() => this.note ? {
|
2020-12-26 10:47:36 +09:00
|
|
|
title: this.$ts.note,
|
2021-09-17 22:39:15 +09:00
|
|
|
subtitle: new Date(this.note.createdAt).toLocaleString(),
|
2020-11-03 20:36:12 +09:00
|
|
|
avatar: this.note.user,
|
2021-04-10 23:52:45 +09:00
|
|
|
path: `/notes/${this.note.id}`,
|
2021-04-10 13:38:24 +09:00
|
|
|
share: {
|
|
|
|
title: this.$t('noteOf', { user: this.note.user.name }),
|
|
|
|
text: this.note.text,
|
|
|
|
},
|
2021-09-17 22:39:15 +09:00
|
|
|
bg: 'var(--bg)',
|
2020-10-17 20:12:00 +09:00
|
|
|
} : null),
|
2020-01-30 04:37:25 +09:00
|
|
|
note: null,
|
2020-11-17 14:59:15 +09:00
|
|
|
clips: null,
|
2020-02-16 22:15:49 +09:00
|
|
|
hasPrev: false,
|
|
|
|
hasNext: false,
|
|
|
|
showPrev: false,
|
|
|
|
showNext: false,
|
2020-01-30 04:37:25 +09:00
|
|
|
error: null,
|
2020-02-16 22:15:49 +09:00
|
|
|
prev: {
|
2022-01-13 02:26:10 +09:00
|
|
|
endpoint: 'users/notes' as const,
|
2020-02-16 22:15:49 +09:00
|
|
|
limit: 10,
|
2022-01-14 12:02:10 +09:00
|
|
|
params: computed(() => ({
|
2020-02-16 22:15:49 +09:00
|
|
|
userId: this.note.userId,
|
|
|
|
untilId: this.note.id,
|
2022-01-14 12:02:10 +09:00
|
|
|
})),
|
2020-02-16 22:15:49 +09:00
|
|
|
},
|
|
|
|
next: {
|
|
|
|
reversed: true,
|
2022-01-13 02:26:10 +09:00
|
|
|
endpoint: 'users/notes' as const,
|
2020-02-16 22:15:49 +09:00
|
|
|
limit: 10,
|
2022-01-14 12:02:10 +09:00
|
|
|
params: computed(() => ({
|
2020-02-16 22:15:49 +09:00
|
|
|
userId: this.note.userId,
|
|
|
|
sinceId: this.note.id,
|
2022-01-14 12:02:10 +09:00
|
|
|
})),
|
2020-02-16 22:15:49 +09:00
|
|
|
},
|
2020-01-30 04:37:25 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
2020-10-25 01:21:41 +09:00
|
|
|
noteId: 'fetch'
|
2020-01-30 04:37:25 +09:00
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
2022-05-19 20:32:55 +09:00
|
|
|
this.hasPrev = false;
|
|
|
|
this.hasNext = false;
|
|
|
|
this.showPrev = false;
|
|
|
|
this.showNext = false;
|
2021-04-17 11:40:47 +09:00
|
|
|
this.note = null;
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('notes/show', {
|
2020-10-25 01:21:41 +09:00
|
|
|
noteId: this.noteId
|
2020-01-30 04:37:25 +09:00
|
|
|
}).then(note => {
|
2021-08-16 15:21:58 +09:00
|
|
|
this.note = note;
|
2020-02-16 22:15:49 +09:00
|
|
|
Promise.all([
|
2020-11-17 14:59:15 +09:00
|
|
|
os.api('notes/clips', {
|
|
|
|
noteId: note.id,
|
|
|
|
}),
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('users/notes', {
|
2020-02-16 22:15:49 +09:00
|
|
|
userId: note.userId,
|
|
|
|
untilId: note.id,
|
|
|
|
limit: 1,
|
|
|
|
}),
|
2020-10-17 20:12:00 +09:00
|
|
|
os.api('users/notes', {
|
2020-02-16 22:15:49 +09:00
|
|
|
userId: note.userId,
|
|
|
|
sinceId: note.id,
|
|
|
|
limit: 1,
|
|
|
|
}),
|
2020-11-17 14:59:15 +09:00
|
|
|
]).then(([clips, prev, next]) => {
|
|
|
|
this.clips = clips;
|
2020-02-16 22:15:49 +09:00
|
|
|
this.hasPrev = prev.length !== 0;
|
|
|
|
this.hasNext = next.length !== 0;
|
|
|
|
});
|
2020-01-30 04:37:25 +09:00
|
|
|
}).catch(e => {
|
|
|
|
this.error = e;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2020-10-17 20:12:00 +09:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-04-17 11:40:47 +09:00
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.125s ease;
|
|
|
|
}
|
|
|
|
.fade-enter-from,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
.fcuexfpr {
|
2021-08-16 15:21:58 +09:00
|
|
|
background: var(--bg);
|
|
|
|
|
2021-10-23 23:22:20 +09:00
|
|
|
> .note {
|
|
|
|
> .main {
|
|
|
|
> .load {
|
|
|
|
min-width: 0;
|
|
|
|
margin: 0 auto;
|
|
|
|
border-radius: 999px;
|
2020-11-17 14:59:15 +09:00
|
|
|
|
2021-10-23 23:22:20 +09:00
|
|
|
&.next {
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
}
|
2020-11-17 14:59:15 +09:00
|
|
|
|
2021-10-23 23:22:20 +09:00
|
|
|
&.prev {
|
|
|
|
margin-top: var(--margin);
|
2020-11-17 14:59:15 +09:00
|
|
|
}
|
2021-10-23 23:22:20 +09:00
|
|
|
}
|
2020-11-17 14:59:15 +09:00
|
|
|
|
2021-10-23 23:22:20 +09:00
|
|
|
> .note {
|
2021-08-16 15:21:58 +09:00
|
|
|
> .note {
|
2021-10-23 23:22:20 +09:00
|
|
|
border-radius: var(--radius);
|
|
|
|
background: var(--panel);
|
2021-08-16 15:21:58 +09:00
|
|
|
}
|
2021-10-23 23:22:20 +09:00
|
|
|
}
|
2021-08-16 15:21:58 +09:00
|
|
|
|
2021-10-23 23:22:20 +09:00
|
|
|
> .clips {
|
|
|
|
> .title {
|
|
|
|
font-weight: bold;
|
|
|
|
padding: 12px;
|
|
|
|
}
|
2020-11-17 14:59:15 +09:00
|
|
|
|
2021-10-23 23:22:20 +09:00
|
|
|
> .item {
|
|
|
|
display: block;
|
|
|
|
padding: 16px;
|
2020-11-17 14:59:15 +09:00
|
|
|
|
2021-10-23 23:22:20 +09:00
|
|
|
> .description {
|
|
|
|
padding: 8px 0;
|
|
|
|
}
|
2020-11-17 14:59:15 +09:00
|
|
|
|
2021-10-23 23:22:20 +09:00
|
|
|
> .user {
|
|
|
|
$height: 32px;
|
|
|
|
padding-top: 16px;
|
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
line-height: $height;
|
2020-11-17 14:59:15 +09:00
|
|
|
|
2021-10-23 23:22:20 +09:00
|
|
|
> .avatar {
|
|
|
|
width: $height;
|
|
|
|
height: $height;
|
2020-11-17 14:59:15 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-17 20:12:00 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|