修复搜索分页功能

- 后端搜索API支持offset参数,返回总数用于分页
- 前端传递offset参数实现正确分页
This commit is contained in:
2026-07-14 00:40:40 +08:00
parent 322ca28cb4
commit 127654a558
2 changed files with 11 additions and 7 deletions
+2 -2
View File
@@ -49,10 +49,10 @@ async function loadArticles() {
});
if (keyword) {
// 搜索时也传递 limit 参数
// 搜索时也传递 limit 和 offset 参数
let searchUrl = `${API_BASE}/api/articles/search?q=${encodeURIComponent(keyword)}`;
if (category) searchUrl += `&category=${encodeURIComponent(category)}`;
searchUrl += `&limit=${pageSize}`;
searchUrl += `&limit=${pageSize}&offset=${(currentPage - 1) * pageSize}`;
const response = await fetch(searchUrl);
const data = await response.json();