feat: add global search bar, fix search cover blur, shelf title search + category tags

1. Fix hdCover() to also replace s_ prefix (search results use s_ not t6_)
2. Add persistent search bar below navbar, switches to discover tab on search
3. Shelf search now supports book title and author search (new keyword param)
4. Add category tag pills above book grid, click to filter by category
5. Update /api/shelf backend: keyword param for title/author, category for exact match
6. Mobile responsive styles for search bar and category tags
This commit is contained in:
admin committed 2026-07-17 12:12:23 +08:00
1 parent 7c918140b3
commit 4c916eceb7
4 files changed
+194 -9

No files matched your search

+10 -5
View File
@@ -498,12 +498,13 @@ def api_time_distribution(conn):
def api_shelf(conn):
"""
书架列表接口(分页)。
返回书架中的书籍列表,支持按分类筛选和只看已读完。
返回书架中的书籍列表,支持按书名/作者搜索、按分类筛选和只看已读完。
Query Parameters:
page (int): 页码,默认 1
per_page (int): 每页数量,默认 60
category (str): 分类筛选(模糊匹配)
keyword (str): 书名或作者搜索(模糊匹配)
category (str): 分类筛选(精确匹配分类名)
finished (str): "1" 表示只看已读完
Returns:
@@ -511,7 +512,8 @@ def api_shelf(conn):
"""
page = int(request.args.get("page", 1))
per_page = int(request.args.get("per_page", 60))
category = request.args.get("category", "")
keyword = request.args.get("keyword", "").strip()
category = request.args.get("category", "").strip()
finished_only = request.args.get("finished", "0") == "1"
offset = (page - 1) * per_page
@@ -520,9 +522,12 @@ def api_shelf(conn):
# 构建查询条件
where_clauses = []
params = []
if keyword:
where_clauses.append("(title LIKE %s OR author LIKE %s)")
params.extend([f"%{keyword}%", f"%{keyword}%"])
if category:
where_clauses.append("category LIKE %s")
params.append(f"%{category}%")
where_clauses.append("category = %s")
params.append(category)
if finished_only:
where_clauses.append("finish_reading=1")