吴雨瞳添加了注释

master
wyt 4 months ago
parent 0a0ed8f6ef
commit 8833797b8a

@ -1,57 +1,77 @@
<template>
<!-- 评论列表过渡组用于评论项添加淡入淡出动画效果 -->
<transition-group name="fade">
<CommentItem v-for="(comment, index) in comments" :key="comment.id" :comment="comment" :index="index">
<!-- 遍历评论列表渲染每个评论项组件 -->
<CommentItem
v-for="(comment, index) in comments"
:key="comment.id"
:comment="comment"
:index="index">
</CommentItem>
</transition-group>
<!-- 加载更多按钮当有更多评论时显示 -->
<button
class="load-more-button mt-7 w-32 text-white p-2 rounded-lg shadow-lg transition transform hover:scale-105 flex mx-auto"
v-if="haveMore">
class="load-more-button mt-7 w-32 text-white p-2 rounded-lg shadow-lg transition transform hover:scale-105 flex mx-auto"
v-if="haveMore">
<!-- 点击按钮触发加载更多评论方法 -->
<span class="text-center flex-grow" @click="loadMore">Load More</span>
</button>
</template>
<script lang="ts">
// @ts-nocheck
// @ts-nocheck TypeScript
// VueAPI
import { defineComponent, inject } from 'vue'
//
import CommentItem from './CommentItem.vue'
//
import { useCommentStore } from '@/stores/comment'
// 线
import emitter from '@/utils/mitt'
//
export default defineComponent({
components: {
CommentItem
CommentItem //
},
setup() {
//
const commentStore = useCommentStore()
//
const loadMore = async () => {
//
switch (commentStore.type) {
case 1:
emitter.emit('articleLoadMore')
emitter.emit('articleLoadMore') //
break
case 2:
emitter.emit('messageLoadMore')
emitter.emit('messageLoadMore') //
break
case 3:
emitter.emit('aboutLoadMore')
emitter.emit('aboutLoadMore') //
break
case 4:
emitter.emit('friendLinkLoadMore')
emitter.emit('friendLinkLoadMore') //
break
case 5:
emitter.emit('talkLoadMore')
emitter.emit('talkLoadMore') //
}
}
return {
comments: inject('comments'),
haveMore: inject('haveMore'),
loadMore
comments: inject('comments'), //
haveMore: inject('haveMore'), //
loadMore //
}
}
})
</script>
<style lang="scss" scoped>
//
.load-more-button {
outline: none;
background: var(--main-gradient);
background: var(--main-gradient); // 使
}
</style>
</style>
Loading…
Cancel
Save