Skip to content

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

@leshalv

Description

@leshalv

需求描述

希望 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:游标模式下,分页器只显示「上一页 / 下一页」,隐藏页码和跳页

使用示例

<ProTable
  request={async (params) => {
    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,
  }}
/>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions