ant-design / ant-design/pro-components

👑 [需求] ProTable 支持 next_token 游标分页

Open
#9,500 0 comments 0 reactions 0 assignees View on GitHub
🎖️ featrue
Dominant language
TypeScript
Stars
4.8k
Forks
1.4k
Avg merge
10h 44m
Merged PRs (30d)
3

Description

## 需求描述

希望 ProTable 支持 **next_token 游标分页**(cursor-based pagination),而不仅限于当前的 offset 分页(current + pageSize)。

## 背景

很多 API(如 AWS、部分云服务、GraphQL 等)使用游标分页,通过 `next_token` / `nextToken` 获取下一页,而不是 `current` 页码。当前 ProTable 的 `request` 只接收 `{ current, pageSize }`,无法直接对接这类接口。

## 期望能力

1. **分页模式**:支持 `pagination.type: 'offset' | 'cursor'`
2. **请求参数**:游标模式下,`request` 能收到 `{ pageSize, nextToken?: string }`(或类似字段)
3. **响应格式**:支持返回 `{ data, success, total?, nextToken? }`,由 ProTable 管理 nextToken 状态
4. **分页 UI**:游标模式下,分页器只显示「上一页 / 下一页」,隐藏页码和跳页

## 使用示例

```
{
const { pageSize, nextToken } = params;
const res = await api.getList({ pageSize, next_token: nextToken });
return {
data: res.items,
success: true,
// 下一页游标
next: res.next_token,
// 可选,部分 API 不返回
total: res.total_count,
};
}}
pagination={{
type: 'cursor',
pageSize: 20,
}}
/>
```

Contributor guide

Open the contributing guide

Research direction

Start with the ProTable request and pagination entry points, comparing the current offset parameters with the proposed cursor parameters and response tokens. Done means cursor mode can request cursor-based pages, render only previous/next controls, and preserve existing offset pagination behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.