From 4e9e750cd7e429e02a731c182fecd6e32f9a3ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E9=B8=BF=E5=AE=87?= Date: Tue, 18 Feb 2025 14:56:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=A8=E9=83=A8=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E4=B8=AD=E5=8F=AA=E6=98=BE=E7=A4=BA=E5=B7=B2=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E7=9A=84=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 史鸿宇 --- apps/manager/appcenter.py | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/apps/manager/appcenter.py b/apps/manager/appcenter.py index 92683afd6..5d5bf3056 100644 --- a/apps/manager/appcenter.py +++ b/apps/manager/appcenter.py @@ -48,35 +48,15 @@ class AppCenterManager: :return: 应用列表, 总应用数 """ try: - # 构建基础搜索条件 - filters: dict[str, Any] = {} - - if keyword and search_type != SearchType.AUTHOR: - # 如果有关键词且不是按作者搜索,则使用原有的过滤逻辑 - filters = AppCenterManager._build_filters( - {"published": True}, - search_type, - keyword, - ) - else: - # 修改为新的搜索条件:author=user_sub 或 published=True - filters = { - "$or": [ - {"author": user_sub}, - {"published": True}, - ], - } - - # 如果有关键词且是按作者搜索,额外添加关键词过滤 - if keyword and search_type == SearchType.AUTHOR: - filters["$and"] = [ - filters["$or"], - {"author": {"$regex": keyword, "$options": "i"}}, - ] - + # 搜索条件,仅显示已发布的应用 + base_filter = {"published": True} + filters: dict[str, Any] = AppCenterManager._build_filters( + {"published": True}, + search_type, + keyword, + ) if keyword else base_filter # 执行应用搜索 apps, total_apps = await AppCenterManager._search_apps_by_filter(filters, page, page_size) - # 构建返回的应用卡片列表 return [ AppCenterCardItem( -- Gitee