All files / src/types pagination.types.ts

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70                                                                                                                    4x                      
/**
 * 分页参数类型定义
 */
 
/**
 * 分页参数(page 风格,推荐使用)
 *
 * 适用于用户界面分页场景
 */
export type PaginationParams = {
  /**
   * 页码(从 1 开始)
   */
  page?: number;
 
  /**
   * 每页数量
   */
  pageSize?: number;
};
 
/**
 * 分页参数(offset 风格)
 *
 * 适用于 API 调用、数据库查询等场景
 */
export type OffsetPaginationParams = {
  /**
   * 限制数量
   */
  limit?: number;
 
  /**
   * 偏移量
   */
  offset?: number;
};
 
/**
 * 游标分页参数
 *
 * 适用于无限滚动、实时数据流场景
 */
export type CursorPaginationParams = {
  /**
   * 游标
   */
  cursor?: string;
 
  /**
   * 限制数量
   */
  limit?: number;
};
 
/**
 * 默认分页配置
 */
export const PAGINATION_DEFAULTS = {
  page: 1,
  pageSize: 20,
  maxPageSize: 100,
  minPageSize: 1,
} as const;
 
/**
 * 默认分页参数类型
 */
export type PaginationDefaults = typeof PAGINATION_DEFAULTS;