feat(留言板): 实现留言点赞功能并优化留言显示

- 新增留言点赞API接口及前端处理逻辑
- 优化留言时间显示格式,使用统一格式化函数
- 修复留言列表props传递问题,支持外部传入articleid
- 移除无用图标和冗余代码,清理样式
This commit is contained in:
qingfeng1121
2025-10-23 18:18:40 +08:00
parent 5b3fba7bfb
commit 6c4d14d06a
5 changed files with 101 additions and 15 deletions

View File

@@ -49,7 +49,7 @@
<!-- 文章操作 -->
<div class="article-actions">
<el-button type="primary" icon="el-icon-arrow-left" @click="goBack" plain>
<el-button type="primary" @click="goBack" plain>
返回
</el-button>
</div>
@@ -74,7 +74,7 @@
<!-- 评论区 -->
<div>
<messageboard class="message-board" v-if="article && Object.keys(article).length > 0" v-model:comments="article.articleid" />
<messageboard class="message-board" v-if="article && Object.keys(article).length > 0" />
</div>
</div>
@@ -84,6 +84,8 @@
import { useRoute, useRouter } from 'vue-router'
import { ref, onMounted } from 'vue'
import { articleService } from '@/services'
import { messageService } from '@/services'
import {categoryAttributeService} from '@/services'
import { ElMessage } from 'element-plus'
import type { Article } from '@/types'
import { formatDate } from '@/utils/dateUtils'
@@ -118,7 +120,7 @@ const fetchArticleDetail = async () => {
if (res.data) {
article.value = res.data
article.value.categoryName = await categoryAttributeService.getAttributeById(article.value.categoryId)|| '未分类'
// 增加文章浏览量
try {
await articleService.incrementArticleViews(Number(articleId))