超管后台 - 客户池分页按钮

This commit is contained in:
柳清爽
2025-04-11 16:19:42 +08:00
parent 0cd689e6ae
commit 31cdc895e6
3 changed files with 36 additions and 2 deletions

View File

@@ -282,6 +282,7 @@ export default function MomentsSyncPage() {
</div> </div>
</div> </div>
<div className="grid grid-cols-2 gap-4 mb-4"> <div className="grid grid-cols-2 gap-4 mb-4">
<div className="text-sm text-gray-500"> <div className="text-sm text-gray-500">
<div>{task.deviceCount} </div> <div>{task.deviceCount} </div>

View File

@@ -38,6 +38,7 @@ class TrafficPool extends Controller
->join('wechat_friend wf', 'tp.wechatId = wf.wechatId', 'left') ->join('wechat_friend wf', 'tp.wechatId = wf.wechatId', 'left')
// 查询字段 // 查询字段
->field([ ->field([
'distinct ts.identifier',
'tp.id', 'tp.id',
'tp.avatar', 'tp.avatar',
'tp.nickname', 'tp.nickname',

View File

@@ -376,15 +376,47 @@ export default function CustomersPage() {
disabled={currentPage <= 1} disabled={currentPage <= 1}
> >
<ChevronLeft className="h-4 w-4" /> <ChevronLeft className="h-4 w-4" />
</Button> </Button>
{/* 数字分页按钮 */}
{Array.from({ length: totalPages }, (_, i) => i + 1).map((page) => {
// 显示当前页码前后2页以及第一页和最后一页
const shouldShow =
page === 1 ||
page === totalPages ||
(page >= currentPage - 2 && page <= currentPage + 2);
if (!shouldShow) {
// 显示省略号
if (page === currentPage - 3 || page === currentPage + 3) {
return (
<span key={page} className="px-2">
...
</span>
);
}
return null;
}
return (
<Button
key={page}
variant={page === currentPage ? "default" : "outline"}
size="sm"
onClick={() => goToPage(page)}
className="min-w-[2.5rem]"
>
{page}
</Button>
);
})}
<Button <Button
variant="outline" variant="outline"
size="sm" size="sm"
onClick={() => goToPage(currentPage + 1)} onClick={() => goToPage(currentPage + 1)}
disabled={currentPage >= totalPages} disabled={currentPage >= totalPages}
> >
<ChevronRight className="h-4 w-4" /> <ChevronRight className="h-4 w-4" />
</Button> </Button>
</div> </div>