[feat]:为主页添加搜索功能

This commit is contained in:
2024-04-21 17:43:26 +08:00
parent 22a3866672
commit df7210d009
3 changed files with 23 additions and 11 deletions

View File

@@ -46,12 +46,17 @@ def new(filename: str, pagenumber:int):
# 获取文件元数据
def getMetadata(form: int, num: int):
def getMetadata(form: int, num: int, search:str = None):
conn = util.getConn()
c = conn.cursor()
cursor = c.execute(
"SELECT * FROM Metadata ORDER BY num desc LIMIT ?, ?", (form, num)
)
if search is None:
cursor = c.execute(
"SELECT * FROM Metadata ORDER BY num desc LIMIT ?, ?", (form, num)
)
else:
cursor = c.execute(
"SELECT * FROM Metadata WHERE filename LIKE ? ORDER BY num desc LIMIT ?, ?", (f"%{search}%", form, num)
)
out = []
for row in cursor:
out.append(list(row))