Skip to content

fix(frontend): pagination 组件未校验 page/pageSize,pageSize=0 导致无限页数 #208

Description

@xiaocheny214

问题描述

文件: frontend/src/shared/ui/pagination.tsx:17

const totalPages = Math.max(1, Math.ceil(total / pageSize))

没有对 pagepageSize 做任何校验:

  • pageSize === 0Math.ceil(total / 0) = InfinitytotalPages = Infinity,"下一页"按钮永远可用
  • page < 0page === 0 → "上一页"按钮启用,点击后 onPageChange(-1)onPageChange(0)
  • pageSize < 0 → 产生异常的分页行为

建议修复

在组件入口处 clamp:

const safePage = Math.max(1, Math.floor(page))
const safePageSize = Math.max(1, Math.floor(pageSize))
const totalPages = Math.max(1, Math.ceil(total / safePageSize))

影响

  • 严重程度: Medium
  • 异常分页状态 → 用户体验损坏

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1优先级 P1(次级)bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions