From 4d923d4196479fa198b148e81564f8a60b230efb Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 13 Aug 2026 10:30:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(community):=20=E5=A4=B4=E5=83=8F=20API?= =?UTF-8?q?=E2=80=94=E2=80=94ugm=20=E6=8C=89=20UserUUID=20=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E6=8E=A5=E5=8F=A3=E6=94=B9=E5=85=AC=E5=BC=80=EF=BC=88?= =?UTF-8?q?AllowAny=EF=BC=89=EF=BC=8C=E7=A4=BE=E5=8C=BA=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=20AuthorAvatar=20=E5=AD=97=E6=AE=B5=EF=BC=9B?= =?UTF-8?q?GVSite=20=E6=8C=87=E9=92=88=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GVSite | 2 +- TempLate/index.html | 2 +- backup/www/index.html | 4 ++-- gvsds/apps/community/views.py | 10 ++++++++++ gvsds/apps/ugm/views.py | 4 +++- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/GVSite b/GVSite index ce8ce23d..84251cd5 160000 --- a/GVSite +++ b/GVSite @@ -1 +1 @@ -Subproject commit ce8ce23d344bf86a96048c8ea8e5dcbb858490bd +Subproject commit 84251cd531819cbb73b510572202b64adc232512 diff --git a/TempLate/index.html b/TempLate/index.html index b5331f3a..9513fa0f 100644 --- a/TempLate/index.html +++ b/TempLate/index.html @@ -5,7 +5,7 @@ 银河锋锐软件开发工作室 - + diff --git a/backup/www/index.html b/backup/www/index.html index fd216eeb..b5331f3a 100644 --- a/backup/www/index.html +++ b/backup/www/index.html @@ -5,8 +5,8 @@ 银河锋锐软件开发工作室 - - + +
diff --git a/gvsds/apps/community/views.py b/gvsds/apps/community/views.py index fa868e8c..5464fc45 100644 --- a/gvsds/apps/community/views.py +++ b/gvsds/apps/community/views.py @@ -75,6 +75,13 @@ def _TimeStr(dt): return str(dt) +def _AvatarURL(user_bytes): + """作者头像 URL(ugm 公开头像接口,按用户 UUID)""" + if not user_bytes: + return '' + return 'https://www.gvsds.com/api/ugm/user-avatar/by-uuid/?UserUUID=' + UUIDObj(user_bytes).str + + class CommunityBoardsView(APIView): """板块列表(含分类与各板块帖子数)""" @@ -134,6 +141,7 @@ class CommunityPostsView(APIView): 'BoardUUID': UUIDObj(p.BoardUUID).str, 'Title': p.Title, 'AuthorName': p.AuthorName, + 'AuthorAvatar': _AvatarURL(p.AuthorUUID), 'ViewCount': p.ViewCount, 'LikeCount': p.LikeCount, 'ReplyCount': p.ReplyCount, @@ -165,6 +173,7 @@ class CommunityPostDetailView(APIView): replies.append({ 'ReplyUUID': UUIDObj(r.ReplyUUID).str, 'AuthorName': r.AuthorName, + 'AuthorAvatar': _AvatarURL(r.AuthorUUID), 'Content': r.Content, 'ReplyToUUID': UUIDObj(r.ReplyToUUID).str if r.ReplyToUUID else '', 'CreateTime': _TimeStr(r.CreateTime), @@ -180,6 +189,7 @@ class CommunityPostDetailView(APIView): 'Title': post.Title, 'Content': post.Content, 'AuthorName': post.AuthorName, + 'AuthorAvatar': _AvatarURL(post.AuthorUUID), 'ViewCount': post.ViewCount, 'LikeCount': post.LikeCount, 'ReplyCount': post.ReplyCount, diff --git a/gvsds/apps/ugm/views.py b/gvsds/apps/ugm/views.py index 58b1c678..6e3c0909 100644 --- a/gvsds/apps/ugm/views.py +++ b/gvsds/apps/ugm/views.py @@ -350,7 +350,9 @@ class GetUserAvatarView(APIView): class GetArgsUserAvatarView(APIView): - permission_classes = [IsAuthenticated] + """按 UserUUID 查询用户头像(公开:社区等对外页面无需登录即可展示头像)""" + + permission_classes = [AllowAny] def get(self, request): user_uuid_str = request.query_params.get('UserUUID')