Merge pull request #997 from nagisa77/codex/add-placeholder-for-no-comments

feat: show placeholder when timeline empty
This commit is contained in:
Tim
2025-09-17 21:20:59 +08:00
committed by GitHub

View File

@@ -122,7 +122,8 @@
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch> <l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
</div> </div>
<div v-else class="comments-container"> <div v-else class="comments-container">
<BaseTimeline :items="timelineItems"> <BasePlaceholder v-if="timelineItems.length === 0" text="暂无评论" icon="inbox" />
<BaseTimeline v-else :items="timelineItems">
<template #item="{ item }"> <template #item="{ item }">
<CommentItem <CommentItem
v-if="item.kind === 'comment'" v-if="item.kind === 'comment'"
@@ -184,6 +185,7 @@ import { useRoute } from 'vue-router'
import CommentItem from '~/components/CommentItem.vue' import CommentItem from '~/components/CommentItem.vue'
import CommentEditor from '~/components/CommentEditor.vue' import CommentEditor from '~/components/CommentEditor.vue'
import BaseTimeline from '~/components/BaseTimeline.vue' import BaseTimeline from '~/components/BaseTimeline.vue'
import BasePlaceholder from '~/components/BasePlaceholder.vue'
import PostChangeLogItem from '~/components/PostChangeLogItem.vue' import PostChangeLogItem from '~/components/PostChangeLogItem.vue'
import ArticleTags from '~/components/ArticleTags.vue' import ArticleTags from '~/components/ArticleTags.vue'
import ArticleCategory from '~/components/ArticleCategory.vue' import ArticleCategory from '~/components/ArticleCategory.vue'
@@ -813,9 +815,7 @@ const fetchCommentsAndChangeLog = async () => {
for (const item of data) { for (const item of data) {
const mappedPayload = const mappedPayload =
item.kind === 'comment' item.kind === 'comment' ? mapComment(item.payload) : mapChangeLog(item.payload)
? mapComment(item.payload)
: mapChangeLog(item.payload)
newTimelineItemList.push(mappedPayload) newTimelineItemList.push(mappedPayload)
if (item.kind === 'comment') { if (item.kind === 'comment') {