fix: harden notification polling and simplify pagination controls

This commit is contained in:
hectorzhao
2026-09-08 21:44:08 +08:00
parent ebb185b22b
commit 6816f56178
15 changed files with 897 additions and 141 deletions
+13 -7
View File
@@ -1,4 +1,4 @@
import { useState, type ReactNode } from 'react';
import { useId, useState, type ReactNode } from 'react';
import { Button } from '@/components/ui/Button';
import { Select } from '@/components/ui/Select';
@@ -80,6 +80,7 @@ export function Pagination({
pageSizeOptions = [10, 25, 50, 100],
onPageSizeChange,
}: PaginationProps) {
const pageSizeId = useId();
const pages = Math.max(1, totalPages ?? (typeof total === 'number' ? Math.ceil(total / (pageSize ?? 10)) : page));
function changePage(nextPage: number) {
@@ -91,12 +92,17 @@ export function Pagination({
{typeof total === 'number' ? <span> {total} </span> : <span />}
<div>
{typeof pageSize === 'number' && onPageSizeChange ? (
<Select
label="每页数量"
value={String(pageSize)}
options={pageSizeOptions.map((value) => ({ value: String(value), label: `${value} 条/页` }))}
onChange={(event) => onPageSizeChange(Number(event.target.value))}
/>
<>
<label className="sr-only" htmlFor={pageSizeId}>
</label>
<Select
id={pageSizeId}
value={String(pageSize)}
options={pageSizeOptions.map((value) => ({ value: String(value), label: `${value} 条/页` }))}
onChange={(event) => onPageSizeChange(Number(event.target.value))}
/>
</>
) : null}
<Button disabled={previousDisabled} onClick={onPrevious} size="sm" variant="ghost">