优化内容库分页
- 默认每页20条 - 列表上部也添加分页控件,方便翻页
This commit is contained in:
@@ -263,6 +263,19 @@
|
|||||||
color: #4caf50;
|
color: #4caf50;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 上部分页 */
|
||||||
|
.pagination-top {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination-top span {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
.article-summary {
|
.article-summary {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #666;
|
color: #666;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const API_BASE = '';
|
|||||||
// 状态
|
// 状态
|
||||||
let articles = [];
|
let articles = [];
|
||||||
let currentPage = 1;
|
let currentPage = 1;
|
||||||
let pageSize = 100;
|
let pageSize = 20; // 默认每页20条
|
||||||
let totalCount = 0;
|
let totalCount = 0;
|
||||||
let selectedIds = new Set();
|
let selectedIds = new Set();
|
||||||
let currentArticleId = null;
|
let currentArticleId = null;
|
||||||
@@ -157,8 +157,14 @@ function displayArticles() {
|
|||||||
// 更新分页
|
// 更新分页
|
||||||
function updatePagination() {
|
function updatePagination() {
|
||||||
const totalPages = Math.ceil(totalCount / pageSize);
|
const totalPages = Math.ceil(totalCount / pageSize);
|
||||||
document.getElementById('page-info').textContent = `第 ${currentPage} / ${totalPages || 1} 页`;
|
|
||||||
|
|
||||||
|
// 更新上部分页
|
||||||
|
document.getElementById('page-info-top').textContent = `第 ${currentPage} / ${totalPages || 1} 页`;
|
||||||
|
document.getElementById('prev-btn-top').disabled = currentPage <= 1;
|
||||||
|
document.getElementById('next-btn-top').disabled = currentPage >= totalPages;
|
||||||
|
|
||||||
|
// 更新下部分页
|
||||||
|
document.getElementById('page-info').textContent = `第 ${currentPage} / ${totalPages || 1} 页`;
|
||||||
document.getElementById('prev-btn').disabled = currentPage <= 1;
|
document.getElementById('prev-btn').disabled = currentPage <= 1;
|
||||||
document.getElementById('next-btn').disabled = currentPage >= totalPages;
|
document.getElementById('next-btn').disabled = currentPage >= totalPages;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,9 +36,9 @@
|
|||||||
<option value="">全部分类</option>
|
<option value="">全部分类</option>
|
||||||
</select>
|
</select>
|
||||||
<select id="page-size" class="page-size-select" onchange="changePageSize()">
|
<select id="page-size" class="page-size-select" onchange="changePageSize()">
|
||||||
<option value="20">每页 20 条</option>
|
<option value="20" selected>每页 20 条</option>
|
||||||
<option value="50">每页 50 条</option>
|
<option value="50">每页 50 条</option>
|
||||||
<option value="100" selected>每页 100 条</option>
|
<option value="100">每页 100 条</option>
|
||||||
<option value="200">每页 200 条</option>
|
<option value="200">每页 200 条</option>
|
||||||
<option value="500">每页 500 条</option>
|
<option value="500">每页 500 条</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -69,6 +69,12 @@
|
|||||||
<i class="ri-delete-bin-line"></i> 批量删除
|
<i class="ri-delete-bin-line"></i> 批量删除
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 上部分页 -->
|
||||||
|
<div class="pagination-top" id="pagination-top">
|
||||||
|
<button onclick="prevPage()" class="btn btn-secondary btn-sm" id="prev-btn-top">上一页</button>
|
||||||
|
<span id="page-info-top">第 1 页</span>
|
||||||
|
<button onclick="nextPage()" class="btn btn-secondary btn-sm" id="next-btn-top">下一页</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="articles-body">
|
<div class="articles-body">
|
||||||
<div id="articles-list" class="articles-list">
|
<div id="articles-list" class="articles-list">
|
||||||
|
|||||||
Reference in New Issue
Block a user