feat(评论): 新增功能开关管理及评论点赞功能优化
- 在管理后台添加功能开关页面,支持控制评论点赞和文章点赞功能的开启/关闭 - 优化评论点赞功能,支持取消点赞和本地存储点赞状态 - 更新点赞UI样式,提升用户体验 - 添加相关API接口和文档说明
This commit is contained in:
@@ -178,7 +178,7 @@ export function createApiClient(config) {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async function likeComment(commentId) {
|
||||
async function likeComment(commentId, isLike = true) {
|
||||
const id =
|
||||
typeof commentId === 'number'
|
||||
? commentId
|
||||
@@ -188,8 +188,9 @@ export function createApiClient(config) {
|
||||
if (!Number.isFinite(id) || id <= 0) {
|
||||
throw new Error('Invalid comment id');
|
||||
}
|
||||
const method = isLike ? 'POST' : 'DELETE';
|
||||
const response = await fetch(`${baseUrl}/api/comments/like`, {
|
||||
method: 'POST',
|
||||
method,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user