refactor(web): 前台代码全面改进

- 搜索逻辑改为后端关键词搜索(修复前端100条限制)
- 合并重复的 handleSelectType/handleDrawerSelectType
- 提取 getLevelText 到公共工具 utils/joke.js
- 删除废弃组件 Header.vue
- 删除重复 API searchJokes
- 修复 AppHeader 滚动事件监听未清理
- 统一 Rightbar URL 参数为 type_ids/crowd_ids
- 清除调试 console.log 代码
- 清理未使用导入 watchEffect
- onMounted 请求并行化(Promise.allSettled)
This commit is contained in:
bwstudio
2026-06-12 08:58:23 +08:00
parent 076812f1aa
commit cab4d6a9bd
11 changed files with 80 additions and 147 deletions
+8
View File
@@ -107,11 +107,19 @@ def list_jokes(
page_size: int = 20,
type_ids: str | None = Query(None, description="逗号分隔的类型 ID,如 1,3,5"),
crowd_ids: str | None = Query(None, description="逗号分隔的人群 ID,如 2,4"),
keyword: str | None = Query(None, description="关键词搜索(标题+内容)"),
db: Session = Depends(get_db),
):
"""获取笑话列表(仅返回已审核通过的笑话)"""
query = db.query(Joke).filter(Joke.status == "approved")
# 关键词搜索:标题和内容模糊匹配
if keyword:
kw = f"%{keyword}%"
query = query.filter(
(Joke.title.like(kw)) | (Joke.content.like(kw))
)
# 支持多选过滤:逗号分隔的 ID
# 使用自定义 JSON 匹配函数避免 LIKE %N% 的错误匹配
if type_ids: