feat(comments): 实现评论点赞功能

- 在数据库和API中添加likes字段支持
- 新增评论点赞接口和前端交互逻辑
- 在前端展示点赞数并处理点赞操作
- 更新相关组件和存储逻辑以支持点赞功能
This commit is contained in:
anghunk
2026-01-22 19:12:33 +08:00
parent 048da0e2ab
commit 9c51339559
13 changed files with 242 additions and 11 deletions

View File

@@ -19,6 +19,7 @@ export type CommentItem = {
contentHtml: string;
status: string;
priority?: number;
likes?: number;
ua?: string | null;
};

View File

@@ -22,6 +22,7 @@
<div class="table-cell table-cell-author">用户</div>
<div class="table-cell table-cell-content">评论信息</div>
<div class="table-cell table-cell-path">评论地址</div>
<div class="table-cell table-cell-likes">点赞</div>
<div class="table-cell table-cell-status">状态</div>
<div class="table-cell table-cell-actions">操作</div>
</div>
@@ -69,6 +70,9 @@
>{{ item.postSlug }}</a
>
</div>
<div class="table-cell table-cell-likes">
<span class="cell-likes-number">{{ typeof item.likes === "number" && Number.isFinite(item.likes) && item.likes >= 0 ? item.likes : 0 }}</span>
</div>
<div class="table-cell table-cell-status">
<div class="cell-status-wrapper">
<span class="cell-status" :class="`cell-status-${item.status}`">
@@ -676,6 +680,12 @@ watch(domainFilter, () => {
flex-shrink: 0;
}
.table-cell-likes {
width: 80px;
flex-shrink: 0;
justify-content: center;
}
.table-cell-time {
width: 150px;
flex-shrink: 0;
@@ -755,6 +765,11 @@ watch(domainFilter, () => {
color: #57606a;
}
.cell-likes-number {
font-size: 13px;
color: #57606a;
}
.cell-author-wrapper {
display: flex;
align-items: flex-start;