完善资源列表查询行为,提供表格公共组件

This commit is contained in:
2025-04-10 17:49:02 +08:00
parent 74c6c01b7d
commit 7238166a95
15 changed files with 1057 additions and 28 deletions

View File

@@ -22,9 +22,9 @@ export interface PaginationProps {
page: number
size: number
total: number
pageSizeOptions?: number[]
onPageChange: (page: number) => void
onPageSizeChange?: (size: number) => void
sizeOptions?: number[]
onPageChange?: (page: number) => void
onSizeChange?: (size: number) => void
className?: string
}
@@ -32,9 +32,9 @@ function Pagination({
page,
size,
total,
pageSizeOptions = [10, 20, 50, 100],
sizeOptions = [10, 20, 50, 100],
onPageChange,
onPageSizeChange,
onSizeChange,
className,
}: PaginationProps) {
const [currentPage, setCurrentPage] = useState(page)
@@ -94,13 +94,13 @@ function Pagination({
return
}
setCurrentPage(newPage)
onPageChange(newPage)
onPageChange?.(newPage)
}
const handlePageSizeChange = (newSize: string) => {
const parsedSize = parseInt(newSize, 10)
if (onPageSizeChange) {
onPageSizeChange(parsedSize)
if (onSizeChange) {
onSizeChange(parsedSize)
}
}
@@ -118,7 +118,7 @@ function Pagination({
<SelectValue/>
</SelectTrigger>
<SelectContent>
{pageSizeOptions.map(option => (
{sizeOptions.map(option => (
<SelectItem key={option} value={option.toString()}>
{option}
</SelectItem>
@@ -216,7 +216,7 @@ function PaginationLink({
data-slot="pagination-link"
data-active={isActive}
className={merge(
'inline-flex items-center justify-center text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-9 w-9 rounded-md border border-input hover:bg-accent hover:text-accent-foreground',
'inline-flex items-center justify-center text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 h-9 w-9 rounded-md border border-input hover:bg-secondary hover:text-secondary-foreground',
isActive && 'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground',
className,
)}