修复搜索分页功能
- 后端搜索API支持offset参数,返回总数用于分页 - 前端传递offset参数实现正确分页
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user