diff --git a/backend/community/views.py b/backend/community/views.py index 445f7b0..2d6ad09 100644 --- a/backend/community/views.py +++ b/backend/community/views.py @@ -284,7 +284,7 @@ class TopicViewSet(viewsets.ModelViewSet): return Response({'error': '请先登录'}, status=401) return super().create(request, *args, **kwargs) - @action(detail=True, methods=['post'], permission_classes=[permissions.IsAuthenticated]) + @action(detail=True, methods=['post'], permission_classes=[permissions.AllowAny]) def like(self, request, pk=None): obj = self.get_object() user = get_current_wechat_user(request) @@ -326,7 +326,7 @@ class ReplyViewSet(viewsets.ModelViewSet): return Response({'error': '请先登录'}, status=401) return super().create(request, *args, **kwargs) - @action(detail=True, methods=['post'], permission_classes=[permissions.IsAuthenticated]) + @action(detail=True, methods=['post'], permission_classes=[permissions.AllowAny]) def like(self, request, pk=None): obj = self.get_object() user = get_current_wechat_user(request) diff --git a/miniprogram/src/subpackages/forum/detail/detail.scss b/miniprogram/src/subpackages/forum/detail/detail.scss index 84b3d31..4704c49 100644 --- a/miniprogram/src/subpackages/forum/detail/detail.scss +++ b/miniprogram/src/subpackages/forum/detail/detail.scss @@ -53,6 +53,31 @@ margin-left: 2px; } } + + .like-btn { + display: flex; + align-items: center; + margin-left: auto; /* Push to right or keep left */ + padding: 6px 14px; + border-radius: 20px; + background-color: rgba(255, 255, 255, 0.08); + border: 1px solid rgba(255, 255, 255, 0.05); + transition: all 0.3s; + + &.active { + background-color: rgba(255, 77, 79, 0.15); + border-color: rgba(255, 77, 79, 0.3); + + text { color: #ff4d4f !important; } + } + + text { + color: #888; + font-size: 14px; + margin-left: 6px; + font-weight: 600; + } + } } } @@ -248,6 +273,46 @@ margin-top: 14px; } } + + .reply-actions { + display: flex; + align-items: center; + margin-top: 12px; + + .reply-like-btn { + display: flex; + align-items: center; + margin-right: 16px; + padding: 4px 10px; + border-radius: 12px; + background-color: rgba(255, 255, 255, 0.03); + transition: all 0.3s; + + &.active { + background-color: rgba(255, 77, 79, 0.12); + text { color: #ff4d4f !important; } + } + + text { + font-size: 12px; + color: #888; + margin-left: 4px; + font-weight: 500; + } + } + + .reply-to-btn { + margin-right: 16px; + padding: 4px 10px; + background: rgba(255,255,255,0.05); + border-radius: 12px; + + text { + font-size: 12px; + color: #aaa; + } + } + } } } } diff --git a/miniprogram/src/subpackages/forum/detail/index.tsx b/miniprogram/src/subpackages/forum/detail/index.tsx index 61514ae..85453dc 100644 --- a/miniprogram/src/subpackages/forum/detail/index.tsx +++ b/miniprogram/src/subpackages/forum/detail/index.tsx @@ -239,9 +239,9 @@ const ForumDetail = () => { {topic.view_count} - - - {topic.like_count || 0} + + + {topic.like_count || 0} {userInfo && topic.author === userInfo.id && ( @@ -283,15 +283,15 @@ const ForumDetail = () => { #{idx + 1} • {new Date(reply.created_at).toLocaleDateString()} - - handleLikeReply(reply.id)} style={{marginRight: 15, display: 'flex', alignItems: 'center', padding: '4px 8px', borderRadius: 4, backgroundColor: reply.is_liked ? '#fff0f0' : 'transparent'}}> - - {reply.like_count || 0} + + handleLikeReply(reply.id)}> + + {reply.like_count || 0} - handleReplyToUser(reply.author_info?.nickname)} style={{marginRight: 10, padding: '2px 6px', background: '#f0f0f0', borderRadius: 4}}> - 回复 + handleReplyToUser(reply.author_info?.nickname)}> + 回复 - +