feat: 实现文章点赞功能及相关API和UI组件

- 新增点赞功能API接口及数据库表结构
- 添加点赞状态管理及UI交互组件
- 实现点赞统计和列表查询功能
- 优化评论组件布局,将点赞按钮加入头部区域
This commit is contained in:
anghunk
2026-01-22 17:40:12 +08:00
parent 83088a3837
commit 103e0ceb25
9 changed files with 675 additions and 20 deletions

View File

@@ -39,6 +39,21 @@
color: var(--cwd-text);
}
.cwd-comments-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 0;
margin-bottom: 16px;
border-bottom: 1px solid var(--cwd-border);
}
.cwd-comments-count {
font-size: 16px;
font-weight: 600;
color: var(--cwd-text);
}
/* ========== Loading 组件 ========== */
.cwd-loading {
display: flex;
@@ -499,6 +514,72 @@
height: auto;
}
.cwd-like {
display: flex;
align-items: center;
gap: 8px;
}
.cwd-like-button {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 4px 10px;
border-radius: 999px;
border: 1px solid var(--cwd-border-light, #eaeef2);
background: var(--cwd-bg-secondary, #f6f8fa);
color: var(--cwd-text-secondary, #6e7781);
cursor: pointer;
font-size: 13px;
font-family: inherit;
transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.cwd-like-button[data-liked='true'] {
background: rgba(9, 105, 218, 0.08);
border-color: var(--cwd-primary, #0969da);
color: var(--cwd-primary, #0969da);
}
.cwd-like-button[data-loading='true'] {
opacity: 0.6;
cursor: default;
pointer-events: none;
}
.cwd-like-icon-wrapper {
display: inline-flex;
align-items: center;
justify-content: center;
}
.cwd-like-icon {
width: 18px;
height: 18px;
fill: currentColor;
}
.cwd-like-count {
min-width: 1.5em;
text-align: right;
}
.cwd-like-animate .cwd-like-icon {
animation: cwd-like-bounce 0.3s ease;
}
@keyframes cwd-like-bounce {
0% {
transform: scale(1);
}
50% {
transform: scale(1.2);
}
100% {
transform: scale(1.05);
}
}
.cwd-comment-actions {
display: flex;
align-items: center;