From 8dfa302b963e2a6f5e3933f8d86416dc02d712db Mon Sep 17 00:00:00 2001 From: xiaji Date: Mon, 15 Jun 2026 07:25:36 +0800 Subject: [PATCH] =?UTF-8?q?fix(search):=20=E6=90=9C=E7=B4=A2=E4=B8=8D?= =?UTF-8?q?=E9=99=90=E6=97=B6=E9=97=B4,=E6=90=9C=E5=85=A8=E9=87=8F?= =?UTF-8?q?=E5=8E=86=E5=8F=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原 list_articles 默认套 24h 时间过滤(line 47-48): if since is None and until is None: since = _default_since_24h() 但用户搜索时(q 不为空)的意图是"找到含某关键字的文章", 跟时间无关;24h 默认会让搜索**找不到 24h 之前的文章**, 即使那篇文章确实包含关键字。 修法:仅在 q 为空时套 24h 默认;有 q 时不套。 显式传 since/until 仍生效(用户要限定时间就显式传)。 不影响: - 普通 list(无 q)仍默认 24h(Feed 首页行为不变) - 显式传 since/until 的 list 行为不变 - 搜索响应 schema 不变(前端无改动) 测试:open web -> Feed -> 搜索 "美联储" -> 看到 24h 之前的 相关文章也能命中。 --- backend/app/api/articles.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/app/api/articles.py b/backend/app/api/articles.py index 5eb6d38..1799c4d 100644 --- a/backend/app/api/articles.py +++ b/backend/app/api/articles.py @@ -43,8 +43,10 @@ async def list_articles( # 公共筛选条件(用于 list + count) filters = [Article.duplicate_of.is_(None)] - # 默认过去 24h - if since is None and until is None: + # 默认过去 24h — 但**搜索时(q 不为空)不限时间**,搜全量历史 + # (用户的搜索意图是"找到含某关键字的文章",跟时间无关; + # 想限定时间显式传 since/until) + if not q and since is None and until is None: since = _default_since_24h() if since: