forked from FoundKeyGang/FoundKey
refactor: welcome.timeline.vue to composition api
This commit is contained in:
parent
9e8b59f886
commit
9fc3fcaf18
1 changed files with 16 additions and 27 deletions
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="civpbkhh">
|
<div class="civpbkhh">
|
||||||
<div ref="scroll" class="scrollbox" v-bind:class="{ scroll: isScrolling }">
|
<div ref="scroll" class="scrollbox" :class="{ scroll: isScrolling }">
|
||||||
<div v-for="note in notes" class="note">
|
<div v-for="note in notes" :key="note.id" class="note">
|
||||||
<div class="content _panel">
|
<div class="content _panel">
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<MkA v-if="note.replyId" class="reply" :to="`/notes/${note.replyId}`"><i class="fas fa-reply"></i></MkA>
|
<MkA v-if="note.replyId" class="reply" :to="`/notes/${note.replyId}`"><i class="fas fa-reply"></i></MkA>
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
<XMediaList :media-list="note.files"/>
|
<XMediaList :media-list="note.files"/>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="note.poll">
|
<div v-if="note.poll">
|
||||||
<XPoll :note="note" :readOnly="true"/>
|
<XPoll :note="note" :read-only="true"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<XReactionsViewer ref="reactionsViewer" :note="note"/>
|
<XReactionsViewer ref="reactionsViewer" :note="note"/>
|
||||||
|
@ -21,37 +21,26 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { defineComponent } from 'vue';
|
import { onUpdated, ref, Ref } from 'vue';
|
||||||
|
import { Note } from 'misskey-js/built/entities';
|
||||||
import XReactionsViewer from '@/components/reactions-viewer.vue';
|
import XReactionsViewer from '@/components/reactions-viewer.vue';
|
||||||
import XMediaList from '@/components/media-list.vue';
|
import XMediaList from '@/components/media-list.vue';
|
||||||
import XPoll from '@/components/poll.vue';
|
import XPoll from '@/components/poll.vue';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
|
import { $i } from '@/account';
|
||||||
|
|
||||||
export default defineComponent({
|
const notes: Ref<Note[]> = ref([]);
|
||||||
components: {
|
const isScrolling = ref(false);
|
||||||
XReactionsViewer,
|
const scroll: Ref<HTMLElement | null> = ref(null);
|
||||||
XMediaList,
|
|
||||||
XPoll
|
|
||||||
},
|
|
||||||
|
|
||||||
data() {
|
os.api('notes/featured').then(newNotes => {
|
||||||
return {
|
notes.value = newNotes;
|
||||||
notes: [],
|
});
|
||||||
isScrolling: false,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
created() {
|
onUpdated(() => {
|
||||||
os.api('notes/featured').then(notes => {
|
if (scroll.value && scroll.value.clientHeight > window.innerHeight) {
|
||||||
this.notes = notes;
|
isScrolling.value = true;
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
updated() {
|
|
||||||
if (this.$refs.scroll.clientHeight > window.innerHeight) {
|
|
||||||
this.isScrolling = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue